/** * @param \CIC\Cicbase\Domain\Model\File $fileObject * @param $storagePath * @return string */ protected function getRelativeDestinationPath(\CIC\Cicbase\Domain\Model\File $fileObject, $storagePath) { $pathInfo = pathinfo($fileObject->getOriginalFilename()); $extension = $pathInfo['extension']; $now = time(); $year = date('Y', $now); $month = date('n', $now); $day = date('j', $now); $relativeDestinationPath = sprintf("%s/%s/%s/%s", $storagePath, $year, $month, $day); return $relativeDestinationPath; }
/** * @param \CIC\Cicbase\Domain\Model\File|\TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy|\TYPO3\CMS\Extbase\Domain\Model\FileReference $file * @param string $class * @param string $linkText * @return string */ public function render($file, $class = null, $linkText = null) { if ($file instanceof \TYPO3\CMS\Extbase\Domain\Model\FileReference) { $uri = $file->getOriginalResource()->getPublicUrl(); } elseif ($file) { $uri = $file->getPathAndFileName(); } else { return ''; } if ($linkText) { $text = $linkText; } elseif ($file->getTitle()) { $text = $file->getTitle(); } else { $text = $file->getOriginalFilename(); } if ($class) { $classAttr = 'class="' . $class . '"'; } else { $classAttr = ''; } return '<a target="_blank" href="' . $uri . '" ' . $classAttr . '>' . $text . '</a>'; }