Exemple #1
0
 /**
  * Creates path for original files on server.
  * If path does not exist, it will be created if given parameter is true.
  *
  * @param Tx_Yag_Domain_Model_Album $album
  * @param bool $createIfNotExists If set to true, directory will be created if it does not exist
  * @return string Path for original images (absolute)
  * @throws Exception
  */
 public function getOrigFileDirectoryPathForAlbum(Tx_Yag_Domain_Model_Album $album, $createIfNotExists = true)
 {
     $path = Tx_Yag_Domain_Configuration_ConfigurationBuilderFactory::getInstance()->buildExtensionConfiguration()->getOrigFilesRootAbsolute() . '/' . $album->getUid() . '/';
     if ($createIfNotExists) {
         $success = Tx_Yag_Domain_FileSystem_Div::checkDirAndCreateIfMissing($path);
         if (!$success) {
             throw new Exception(sprintf('The original file path %s  for album %s could not be created!', $path, $album->getUid()), 1404452464);
         }
     }
     return $path;
 }
 /**
  * Initializes configuration object (Template method)
  */
 protected function init()
 {
     $this->setRequiredValue('hashFilesystemRoot', 'No Extension Configuration setting for hashFilesystemRoot! Change this in Extension Manager! 1293418501');
     if (!Tx_Yag_Domain_FileSystem_Div::checkDirAndCreateIfMissing($this->getHashFilesystemRootAbsolute())) {
         throw new Exception('Hash filesystem root does not exist. Make sure to create directory ' . $this->getHashFilesystemRootAbsolute() . ' 1293418502');
     }
     $this->setRequiredValue('origFilesRoot', 'No Extension Configuration setting for origFilesRoot! Change this in Extension Manager! 1293486046');
     if (!Tx_Yag_Domain_FileSystem_Div::checkDirAndCreateIfMissing($this->getOrigFilesRootAbsolute())) {
         throw new Exception('Directory for original files does not exist. Make sure to create directory ' . $this->getOrigFilesRootAbsolute() . ' 1293486047');
     }
     $this->sysDateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'];
 }
Exemple #3
0
 /**
  * Adds a file from the local server hard disk to a given path in TYPO3s virtual file system.
  *
  * This assumes that the local file exists, so no further check is done here!
  *
  * @param string $localFilePath
  * @param \TYPO3\CMS\Core\Resource\Folder $targetFolder
  * @param string $fileName The name to add the file under
  * @param \TYPO3\CMS\Core\Resource\AbstractFile $updateFileObject Optional file object to update (instead of creating a new object). With this parameter, this function can be used to "populate" a dummy file object with a real file underneath.
  * @return \TYPO3\CMS\Core\Resource\FileInterface
  */
 public function addFile($localFilePath, \TYPO3\CMS\Core\Resource\Folder $targetFolder, $fileName, \TYPO3\CMS\Core\Resource\AbstractFile $updateFileObject = null)
 {
     // TODO: Implement addFile() method.
     error_log('FAL DRIVER: ' . __FUNCTION__ . ' Folder: ' . $targetFolder->getCombinedIdentifier() . ' FileName ' . $fileName) . 'FileObject ';
     if ($targetFolder == $this->storage->getProcessingFolder()) {
         $yagTempFolder = 'typo3temp/yag';
         // TODO: use configured value
         $falTempFolder = $this->yagFileSystemDiv->makePathAbsolute($yagTempFolder . $targetFolder->getIdentifier());
         $this->yagFileSystemDiv->checkDirAndCreateIfMissing($falTempFolder);
         $falTempFilePath = \Tx_Yag_Domain_FileSystem_Div::concatenatePaths(array($falTempFolder, $fileName));
         rename($localFilePath, $falTempFilePath);
     }
     return $this->getFile($falTempFilePath);
 }
Exemple #4
0
 /**
  * Creates a path for a given ID and returns path
  *
  * @param int $fileId
  * @return string Absolute path for given File ID
  */
 public function createAndGetAbsolutePathById($fileId)
 {
     $path = $this->getAbsolutePathById($fileId);
     Tx_Yag_Domain_FileSystem_Div::checkDirAndCreateIfMissing(PATH_site . $path);
     return $path;
 }
Exemple #5
0
 /**
  * @test
  * @dataProvider checkDirAndCreateIfMissingDataProvider
  */
 public function checkDirAndCreateIfMissing($directoryToCreate)
 {
     $result = $this->fileSystemDiv->checkDirAndCreateIfMissing($directoryToCreate);
     $this->assertTrue($result);
     $this->assertTrue(is_dir($directoryToCreate));
 }