/** * Retrieve page details from given page id * * @param integer $storageId * @param string $location * @return string Rendered string */ public function render($storageId, $location = '/') { $output = null; if (!isset($this->storage[$storageId]) || !$this->storage[$storageId] instanceof \TYPO3\CMS\Core\Resource\ResourceStorage) { try { $this->storage[$storageId] = $this->storageRepository->findByUid($storageId); } catch (\Exception $e) { } } /** @var \TYPO3\CMS\Core\Resource\ResourceStorage $storage */ $storage = $this->storage[$storageId]; if ($storage instanceof \TYPO3\CMS\Core\Resource\ResourceStorage) { $folder = null; try { $folder = $storage->getFolder($location); } catch (\Exception $e) { } if ($folder instanceof \TYPO3\CMS\Core\Resource\Folder) { $output = $folder->getPublicUrl(); } } if (empty($output)) { $output = $storageId . ': ' . $location; } return $output; }
/** * Returns a ResourceStorage for a given uid * * @param int $storageUid * @return ResourceStorage * @throws PersistenceManagerException */ protected function getStorageByUid(int $storageUid) : ResourceStorage { $storage = $this->storageRepository->findByUid($storageUid); if (!$storage instanceof ResourceStorage || !$storage->isBrowsable()) { throw new PersistenceManagerException(sprintf('Could not access storage with uid "%d".', $storageUid), 1471630581); } return $storage; }
/** * @param $relFolderPath * @param $pathExists * @return \TYPO3\CMS\Core\Resource\Folder */ protected function createFolderObject($relFolderPath, $pathExists) { if (!$pathExists) { $storage = $this->folderRepository->findByUid(1); return $this->fileFactory->createFolderObject($storage, $relFolderPath, 'upload_folder'); } else { return $this->fileFactory->getFolderObjectFromCombinedIdentifier("1:{$relFolderPath}"); } }
/** * Convert all PNG images (except processed) from specified storage. * * @param int $storageUid * @return boolean */ public function convertStorage($storageUid) { $this->storageRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class); $storage = $this->storageRepository->findByUid($storageUid); if ($storage) { // Convert all storage files $files = $storage->getFilesInFolder($storage->getRootLevelFolder(FALSE), 0, 0, TRUE, TRUE); foreach ($files as $file) { if ($file instanceof File) { $this->convertPngImage($file); } unset($file); } } else { $this->logger->error('No storage found', array('storage' => $storageUid)); return FALSE; } }
/** * Constructor * * @param StorageRepository $repository Application StorageRepository */ public function __construct(StorageRepository $repository) { $this->storage = $repository->findByUid(self::$fileadminStorageId); }
/** * Set the storage and folder to use for the Plugins * * @throws \Exception * @throws \TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException * @return void */ protected function resolveStorageInformation() { $selectedFolderParts = explode(':', $this->settings['default']['folder']); $this->selectedStorage = $this->storageRepository->findByUid($selectedFolderParts[1]); $this->selectedFolder = $this->selectedStorage->getFolder($selectedFolderParts[2]); }
/** * @param Share $share * @return \TYPO3\CMS\Core\Resource\File[] */ private function getFilesFromShare(Share $share) { $storage = $this->storageRepository->findByUid($share->getStorage()); $folder = $storage->getFolder($share->getFolder()); return $folder->getFiles(); }