public function testGetAttachmentIconClass() { $this->attachment->setExtension('txt'); $this->assertEquals('icon_txt', $this->attachmentManager->getAttachmentIconClass($this->attachment)); $this->attachment->setExtension('doc'); $this->assertEquals('icon_default', $this->attachmentManager->getAttachmentIconClass($this->attachment)); }
/** * Get file view html block * * @param \Twig_Environment $environment * @param object $parentEntity * @param string $fieldName * @param File $attachment * @return string */ public function getFileView(\Twig_Environment $environment, $parentEntity, $fieldName, $attachment = null) { /** * @todo: should be refactored in BAP-5637 */ if (is_int($attachment)) { $attachment = $this->getFileById($attachment); } if ($attachment && $attachment->getFilename()) { return $environment->loadTemplate(self::FILES_TEMPLATE)->render(['iconClass' => $this->manager->getAttachmentIconClass($attachment), 'url' => $this->manager->getFileUrl($parentEntity, $fieldName, $attachment, 'download', true), 'fileName' => $attachment->getOriginalFilename()]); } return ''; }