FAIconGenerator = $FAIconGenerator; $this->urlGenerator = $urlGenerator; } /** * The normalize function is responsible for converting parsed and processed data to a datatables-appropriate type. * * @param mixed $value The single value of the column * @return mixed */ public function normalize($value) { return $value; } public function render($value, $context) { if (!$context instanceof Part) { throw new \RuntimeException('$context must be a Part object!'); } $tmp = ""; $attachments = $context->getAttachments()->filter(function (Attachment $attachment) { return $attachment->getShowInTable(); }); $count = 5; foreach ($attachments as $attachment) { //Only show the first 5 attachments if (--$count < 0) { break; } /** @var Attachment $attachment */ $tmp .= sprintf( '%s', $this->urlGenerator->getViewURL($attachment), htmlspecialchars($attachment->getName()) . ': ' . htmlspecialchars($attachment->getFilename()), $this->FAIconGenerator->generateIconHTML( $this->FAIconGenerator->fileExtensionToFAType($attachment->getExtension()), 'fas', 'fa-2x' ) ); } return $tmp; } public function configureOptions(OptionsResolver $resolver) { parent::configureOptions($resolver); } }