/**
  * Builds a temporary directory to work on.
  * @return void
  */
 protected function prepareTemporaryDirectory()
 {
     $this->temporaryDirectory = \TYPO3\Flow\Utility\Files::concatenatePaths(array(FLOW_PATH_DATA, 'Temporary', 'Testing', str_replace('\\', '_', __CLASS__)));
     if (!file_exists($this->temporaryDirectory)) {
         \TYPO3\Flow\Utility\Files::createDirectoryRecursively($this->temporaryDirectory);
     }
 }
예제 #2
0
 /**
  * @param string $filename
  * @return string
  * @throws \TYPO3\Flow\Utility\Exception
  */
 public function getDocumentAbsolutePath($filename = null)
 {
     $path = str_replace('\\', '/', get_called_class());
     $documentAbsolutePath = $this->temporaryDirectoryBase . $path . '/';
     Files::createDirectoryRecursively($documentAbsolutePath);
     return Files::getNormalizedPath($documentAbsolutePath) . $filename;
 }
 /**
  * @param string $subject
  * @param boolean $exclusiveLock TRUE to, acquire an exclusive (write) lock, FALSE for a shared (read) lock.
  * @throws LockNotAcquiredException
  * @throws \TYPO3\Flow\Utility\Exception
  * @return void
  */
 public function acquire($subject, $exclusiveLock)
 {
     if ($this->isWindowsOS()) {
         return;
     }
     if (self::$temporaryDirectory === null) {
         if (Bootstrap::$staticObjectManager === null || !Bootstrap::$staticObjectManager->isRegistered(\TYPO3\Flow\Utility\Environment::class)) {
             throw new LockNotAcquiredException('Environment object could not be accessed', 1386680952);
         }
         $environment = Bootstrap::$staticObjectManager->get(\TYPO3\Flow\Utility\Environment::class);
         $temporaryDirectory = Files::concatenatePaths(array($environment->getPathToTemporaryDirectory(), 'Lock'));
         Files::createDirectoryRecursively($temporaryDirectory);
         self::$temporaryDirectory = $temporaryDirectory;
     }
     $this->lockFileName = Files::concatenatePaths(array(self::$temporaryDirectory, md5($subject)));
     if (($this->filePointer = @fopen($this->lockFileName, 'r')) === false) {
         if (($this->filePointer = @fopen($this->lockFileName, 'w')) === false) {
             throw new LockNotAcquiredException(sprintf('Lock file "%s" could not be opened', $this->lockFileName), 1386520596);
         }
     }
     if ($exclusiveLock === false && flock($this->filePointer, LOCK_SH) === true) {
         // Shared lock acquired
     } elseif ($exclusiveLock === true && flock($this->filePointer, LOCK_EX) === true) {
         // Exclusive lock acquired
     } else {
         throw new LockNotAcquiredException(sprintf('Could not lock file "%s"', $this->lockFileName), 1386520597);
     }
 }
 /**
  * Factory method which creates an EntityManager.
  *
  * @return \Doctrine\ORM\EntityManager
  */
 public function create()
 {
     $config = new \Doctrine\ORM\Configuration();
     $config->setClassMetadataFactoryName('TYPO3\\Flow\\Persistence\\Doctrine\\Mapping\\ClassMetadataFactory');
     $cache = new \TYPO3\Flow\Persistence\Doctrine\CacheAdapter();
     // must use ObjectManager in compile phase...
     $cache->setCache($this->objectManager->get('TYPO3\\Flow\\Cache\\CacheManager')->getCache('Flow_Persistence_Doctrine'));
     $config->setMetadataCacheImpl($cache);
     $config->setQueryCacheImpl($cache);
     $resultCache = new \TYPO3\Flow\Persistence\Doctrine\CacheAdapter();
     // must use ObjectManager in compile phase...
     $resultCache->setCache($this->objectManager->get('TYPO3\\Flow\\Cache\\CacheManager')->getCache('Flow_Persistence_Doctrine_Results'));
     $config->setResultCacheImpl($resultCache);
     if (class_exists($this->settings['doctrine']['sqlLogger'])) {
         $config->setSQLLogger(new $this->settings['doctrine']['sqlLogger']());
     }
     $eventManager = $this->buildEventManager();
     $flowAnnotationDriver = $this->objectManager->get('TYPO3\\Flow\\Persistence\\Doctrine\\Mapping\\Driver\\FlowAnnotationDriver');
     $config->setMetadataDriverImpl($flowAnnotationDriver);
     $proxyDirectory = \TYPO3\Flow\Utility\Files::concatenatePaths(array($this->environment->getPathToTemporaryDirectory(), 'Doctrine/Proxies'));
     \TYPO3\Flow\Utility\Files::createDirectoryRecursively($proxyDirectory);
     $config->setProxyDir($proxyDirectory);
     $config->setProxyNamespace('TYPO3\\Flow\\Persistence\\Doctrine\\Proxies');
     $config->setAutoGenerateProxyClasses(FALSE);
     $entityManager = \Doctrine\ORM\EntityManager::create($this->settings['backendOptions'], $config, $eventManager);
     $flowAnnotationDriver->setEntityManager($entityManager);
     \Doctrine\DBAL\Types\Type::addType('objectarray', 'TYPO3\\Flow\\Persistence\\Doctrine\\DataTypes\\ObjectArray');
     if (isset($this->settings['doctrine']['filters']) && is_array($this->settings['doctrine']['filters'])) {
         foreach ($this->settings['doctrine']['filters'] as $filterName => $filterClass) {
             $config->addFilter($filterName, $filterClass);
             $entityManager->getFilters()->enable($filterName);
         }
     }
     return $entityManager;
 }
 protected function setUp()
 {
     $this->prepareTestPaths();
     Files::createDirectoryRecursively($this->testFilePath);
     touch($this->logFilePath);
     $this->schedulerTaskId = $this->getTestTaskId();
 }
 /**
  * Move resource files to the new locations and adjust records.
  *
  * @param Schema $schema
  * @return void
  */
 public function postUp(Schema $schema)
 {
     $resourcesResult = $this->connection->executeQuery('SELECT persistence_object_identifier, sha1, filename FROM typo3_flow_resource_resource');
     while ($resourceInfo = $resourcesResult->fetch(\PDO::FETCH_ASSOC)) {
         $resourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $resourceInfo['sha1'];
         $newResourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $resourceInfo['sha1'][0] . '/' . $resourceInfo['sha1'][1] . '/' . $resourceInfo['sha1'][2] . '/' . $resourceInfo['sha1'][3] . '/' . $resourceInfo['sha1'];
         $mediaType = MediaTypes::getMediaTypeFromFilename($resourceInfo['filename']);
         if (file_exists($resourcePathAndFilename)) {
             $md5 = md5_file($resourcePathAndFilename);
             $filesize = filesize($resourcePathAndFilename);
             if (!file_exists(dirname($newResourcePathAndFilename))) {
                 Files::createDirectoryRecursively(dirname($newResourcePathAndFilename));
             }
             $result = @rename($resourcePathAndFilename, $newResourcePathAndFilename);
         } elseif (file_exists($newResourcePathAndFilename)) {
             $md5 = md5_file($newResourcePathAndFilename);
             $filesize = filesize($newResourcePathAndFilename);
             $result = TRUE;
         } else {
             $this->write(sprintf('Error while migrating database for the new resource management: the resource file "%s" (original filename: %s) was not found, but the resource object with uuid %s needs this file.', $resourcePathAndFilename, $resourceInfo['filename'], $resourceInfo['persistence_object_identifier']));
             continue;
         }
         $this->connection->executeUpdate('UPDATE typo3_flow_resource_resource SET collectionname = ?, mediatype = ?, md5 = ?, filesize = ? WHERE persistence_object_identifier = ?', array('persistent', $mediaType, $md5, $filesize, $resourceInfo['persistence_object_identifier']));
         if ($result === FALSE) {
             $this->write(sprintf('Could not move the data file of resource "%s" from its legacy location at %s to the correct location %s.', $resourceInfo['sha1'], $resourcePathAndFilename, $newResourcePathAndFilename));
         }
     }
     $this->connection->exec('ALTER TABLE typo3_flow_resource_resource ALTER md5 SET NOT NULL');
     $this->connection->exec('ALTER TABLE typo3_flow_resource_resource ALTER collectionname SET NOT NULL');
     $this->connection->exec('ALTER TABLE typo3_flow_resource_resource ALTER mediatype SET NOT NULL');
     $this->connection->exec('ALTER TABLE typo3_flow_resource_resource ALTER filesize SET NOT NULL');
 }
 /**
  * Make sure required paths and files are available outside of Package
  * Run on every Composer install or update - must be configured in root manifest
  *
  * @param CommandEvent $event
  * @return void
  */
 public static function postUpdateAndInstall(CommandEvent $event)
 {
     Files::createDirectoryRecursively('Configuration');
     Files::createDirectoryRecursively('Data');
     Files::copyDirectoryRecursively('Packages/Framework/TYPO3.Flow/Resources/Private/Installer/Distribution/Essentials', './', false, true);
     Files::copyDirectoryRecursively('Packages/Framework/TYPO3.Flow/Resources/Private/Installer/Distribution/Defaults', './', true, true);
     chmod('flow', 0755);
 }
예제 #8
0
 public function __construct()
 {
     parent::__construct();
     $this->dumpDirectory = FLOW_PATH_DATA . 'Persistent/GermaniaSacra/Dump/';
     if (!file_exists($this->dumpDirectory)) {
         Files::createDirectoryRecursively($this->dumpDirectory);
     }
 }
 /**
  * @test
  */
 public function getLanguagesScansFormatDirectoryAndReturnsLanguagesAsStrings()
 {
     $formatPath = vfsStream::url('testDirectory') . '/';
     \TYPO3\Flow\Utility\Files::createDirectoryRecursively($formatPath . 'en');
     $format = new \TYPO3\Flow\Package\Documentation\Format('DocBook', $formatPath);
     $availableLanguages = $format->getAvailableLanguages();
     $this->assertEquals(array('en'), $availableLanguages);
 }
 /**
  * @test
  */
 public function getDocumentationFormatsScansDocumentationDirectoryAndReturnsDocumentationFormatObjectsIndexedByFormatName()
 {
     $documentationPath = vfsStream::url('testDirectory') . '/';
     $mockPackage = $this->getMock(\TYPO3\Flow\Package\PackageInterface::class);
     \TYPO3\Flow\Utility\Files::createDirectoryRecursively($documentationPath . 'DocBook/en');
     $documentation = new \TYPO3\Flow\Package\Documentation($mockPackage, 'Manual', $documentationPath);
     $documentationFormats = $documentation->getDocumentationFormats();
     $this->assertEquals('DocBook', $documentationFormats['DocBook']->getFormatName());
 }
 /**
  * @test
  */
 public function importTemporaryFileSkipsFilesThatAlreadyExist()
 {
     $mockTempFile = vfsStream::newFile('SomeTemporaryFile', 0333)->withContent('fixture')->at($this->mockDirectory);
     $finalTargetPathAndFilename = $this->writableFileSystemStorage->_call('getStoragePathAndFilenameByHash', sha1('fixture'));
     Files::createDirectoryRecursively(dirname($finalTargetPathAndFilename));
     file_put_contents($finalTargetPathAndFilename, 'existing file');
     $this->writableFileSystemStorage->_call('importTemporaryFile', $mockTempFile->url(), 'default');
     $this->assertSame('existing file', file_get_contents($finalTargetPathAndFilename));
 }
 /**
  */
 public function setUp()
 {
     vfsStream::setup('Foo');
     $temporaryDirectoryBase = realpath(sys_get_temp_dir()) . '/' . str_replace('\\', '_', __CLASS__);
     $this->temporaryDirectoryPath = \TYPO3\Flow\Utility\Files::concatenatePaths(array($temporaryDirectoryBase, 'FlowPrivateResourcesPublishingAspectTestTemporaryDirectory'));
     \TYPO3\Flow\Utility\Files::createDirectoryRecursively($this->temporaryDirectoryPath);
     $this->publishPath = \TYPO3\Flow\Utility\Files::concatenatePaths(array($temporaryDirectoryBase, 'FlowPrivateResourcesPublishingAspectTestPublishDirectory'));
     \TYPO3\Flow\Utility\Files::createDirectoryRecursively($this->publishPath);
 }
예제 #13
0
 /**
  * @param StatsProcessorProcessible $simulation
  */
 protected function copyStats(StatsProcessorProcessible $simulation)
 {
     $statsOutputDirectory = Files::concatenatePaths(array($this->statsOutputPath, $simulation->getCombinedSimulationName()));
     Files::createDirectoryRecursively($statsOutputDirectory);
     $statsSourcePath = $simulation->getReportFilePath();
     $statsTargetPath = Files::concatenatePaths(array($statsOutputDirectory, 'LastBuild.json'));
     $this->logger->log(sprintf("Copy global stats %s to %s\n", $statsSourcePath, $statsTargetPath));
     copy($statsSourcePath, $statsTargetPath);
 }
예제 #14
0
 /**
  * @param array $settings
  */
 public function injectSettings(array $settings)
 {
     if (isset($settings['yamlPersistenceManager']['savePath'])) {
         $this->savePath = $settings['yamlPersistenceManager']['savePath'];
         if (!is_dir($this->savePath)) {
             \TYPO3\Flow\Utility\Files::createDirectoryRecursively($this->savePath);
         }
     }
 }
예제 #15
0
 /**
  * Sets the temporaryDirectory as static variable for the lock class.
  *
  * @throws LockNotAcquiredException
  * @throws \TYPO3\Flow\Utility\Exception
  * return void;
  */
 protected function configureTemporaryDirectory()
 {
     if (Bootstrap::$staticObjectManager === null || !Bootstrap::$staticObjectManager->isRegistered(\TYPO3\Flow\Utility\Environment::class)) {
         throw new LockNotAcquiredException('Environment object could not be accessed', 1386680952);
     }
     $environment = Bootstrap::$staticObjectManager->get('TYPO3\\Flow\\Utility\\Environment');
     $temporaryDirectory = Files::concatenatePaths([$environment->getPathToTemporaryDirectory(), 'Lock']);
     Files::createDirectoryRecursively($temporaryDirectory);
     self::$temporaryDirectory = $temporaryDirectory;
 }
예제 #16
0
 /**
  * @Given /^the recipient list is:$/
  */
 public function theRecipientListIs(TableNode $table)
 {
     $content = '';
     $receiverGroup = new \Sandstorm\Newsletter\Domain\Model\ReceiverSource();
     foreach ($table->getHash() as $row) {
         $content .= json_encode($row) . "\n";
     }
     Files::createDirectoryRecursively(dirname($receiverGroup->getCacheFileName()));
     file_put_contents($receiverGroup->getCacheFileName(), $content);
     $this->newsletter->setReceiverGroup($receiverGroup);
 }
 /**
  * Executes this task
  *
  * @param \TYPO3\Surf\Domain\Model\Node $node
  * @param \TYPO3\Surf\Domain\Model\Application $application
  * @param \TYPO3\Surf\Domain\Model\Deployment $deployment
  * @param array $options
  * @return void
  * @throws \TYPO3\Surf\Exception\TaskExecutionException
  */
 public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
 {
     $this->hosting = $application->getOption('hosting');
     $this->username = $options['username'];
     $this->hostname = $node->getHostname();
     $this->deployment = $deployment;
     $this->resourcePath = $this->packageManager->getPackage('Famelo.Surf.SharedHosting')->getResourcesPath() . 'Private/' . $this->hosting;
     $this->temporaryPath = FLOW_PATH_ROOT . '/Data/Temporary/Deployment/' . $this->hosting;
     if (!is_dir($this->temporaryPath)) {
         \TYPO3\Flow\Utility\Files::createDirectoryRecursively($this->temporaryPath);
     }
 }
 /**
  * @param ReceiverGroup $receiverGroup
  */
 public function generate(ReceiverGroup $receiverGroup)
 {
     Files::createDirectoryRecursively($this->receiverGroupCache);
     $presets = $this->contentDimensionPresetSource->getAllPresets();
     $languages = array_keys($presets['language']['presets']);
     if (count($languages) == 0) {
         $this->processReceiverGroup($receiverGroup);
     } else {
         foreach ($languages as $language) {
             $this->processReceiverGroup($receiverGroup, $language);
         }
     }
 }
예제 #19
0
 public function initializeOrUpdate()
 {
     $localCopyForCsvFile = $this->sourceFile->createTemporaryLocalCopy();
     $csvReader = Reader::createFromPath($localCopyForCsvFile);
     $csvReader->setDelimiter(';');
     $csv = $csvReader->fetchAssoc();
     $output = array();
     foreach ($csv as $row) {
         $output[] = json_encode($row);
     }
     Files::createDirectoryRecursively(dirname($this->getSourceFileName()));
     file_put_contents($this->getSourceFileName(), implode("\n", $output));
     parent::initializeOrUpdate();
 }
 /**
  * @param string $value
  * @throws Exception
  * @throws \TYPO3\Flow\Resource\Exception
  * @throws \TYPO3\Flow\Utility\Exception
  */
 protected function initializeValue($value)
 {
     if (!is_array($value)) {
         throw new Exception('Value must be an array, with source URI (sourceUri) and filename (filename)', 1425981082);
     }
     if (!isset($value['sourceUri'])) {
         throw new Exception('Missing source URI', 1425981083);
     }
     $sourceUri = trim($value['sourceUri']);
     if (!isset($value['filename'])) {
         throw new Exception('Missing filename URI', 1425981084);
     }
     $filename = trim($value['filename']);
     $overrideFilename = isset($value['overrideFilename']) ? trim($value['overrideFilename']) : $filename;
     if (!isset($this->options['downloadDirectory'])) {
         throw new Exception('Missing download directory data type option', 1425981085);
     }
     Files::createDirectoryRecursively($this->options['downloadDirectory']);
     $temporaryFileAndPathname = trim($this->options['downloadDirectory'] . $filename);
     $this->download($sourceUri, $temporaryFileAndPathname);
     $sha1Hash = sha1_file($temporaryFileAndPathname);
     # Try to add file extenstion if missing
     if (!$this->downloadCache->has($sha1Hash)) {
         $fileExtension = pathinfo($temporaryFileAndPathname, PATHINFO_EXTENSION);
         if (trim($fileExtension) === '') {
             $mimeTypeGuesser = new MimeTypeGuesser();
             $mimeType = $mimeTypeGuesser->guess($temporaryFileAndPathname);
             $this->logger->log(sprintf('Try to guess mime type for "%s" (%s), result: %s', $sourceUri, $filename, $mimeType), LOG_DEBUG);
             $fileExtension = MediaTypes::getFilenameExtensionFromMediaType($mimeType);
             if ($fileExtension !== '') {
                 $oldTemporaryDestination = $temporaryFileAndPathname;
                 $temporaryDestination = $temporaryFileAndPathname . '.' . $fileExtension;
                 copy($oldTemporaryDestination, $temporaryDestination);
                 $this->logger->log(sprintf('Rename "%s" to "%s"', $oldTemporaryDestination, $temporaryDestination), LOG_DEBUG);
             }
         }
     }
     $resource = $this->resourceManager->getResourceBySha1($sha1Hash);
     if ($resource === NULL) {
         $resource = $this->resourceManager->importResource($temporaryFileAndPathname);
         if ($filename !== $overrideFilename) {
             $resource->setFilename($overrideFilename);
         }
     }
     $this->temporaryFileAndPathname = $temporaryFileAndPathname;
     $this->downloadCache->set($sha1Hash, ['sha1Hash' => $sha1Hash, 'filename' => $filename, 'sourceUri' => $sourceUri, 'temporaryFileAndPathname' => $temporaryFileAndPathname]);
     $this->value = $resource;
 }
예제 #21
0
 /**
  * Gets the patch as zip package from gerrit
  *
  * @param int $patchId
  * @return bool|string
  * @throws \TYPO3\Flow\Utility\Exception
  */
 public function getPatchFromGerrit($patchId)
 {
     $uri = sprintf($this->gerritApiPattern, $patchId, 'revisions/current/patch?zip');
     $outputDirectory = Files::concatenatePaths(array($this->environment->getPathToTemporaryDirectory(), 'GerritPatches'));
     Files::createDirectoryRecursively($outputDirectory);
     $outputZipFilePath = Files::concatenatePaths(array($outputDirectory, $patchId . '.zip'));
     $httpClient = new Client();
     $httpClient->get($uri)->setResponseBody($outputZipFilePath)->send();
     $zip = new \ZipArchive();
     $zip->open($outputZipFilePath);
     $patchFile = $zip->getNameIndex(0);
     $zip->extractTo($outputDirectory);
     $zip->close();
     Files::unlink($outputZipFilePath);
     return Files::concatenatePaths(array($outputDirectory, $patchFile));
 }
예제 #22
0
 /**
  * Invokes custom PHP code directly after the package manager has been initialized.
  *
  * @param Bootstrap $bootstrap The current bootstrap
  * @return void
  */
 public function boot(Bootstrap $bootstrap)
 {
     if (!file_exists(FLOW_PATH_DATA . 'Logs')) {
         Files::createDirectoryRecursively(FLOW_PATH_DATA . 'Logs');
     }
     $monologFactory = LoggerFactory::getInstance();
     $bootstrap->setEarlyInstance(LoggerFactory::class, $monologFactory);
     $dispatcher = $bootstrap->getSignalSlotDispatcher();
     $dispatcher->connect('TYPO3\\Flow\\Core\\Booting\\Sequence', 'afterInvokeStep', function ($step) use($bootstrap, $dispatcher) {
         if ($step->getIdentifier() === 'typo3.flow:configuration') {
             /** @var ConfigurationManager $configurationManager */
             $configurationManager = $bootstrap->getEarlyInstance(ConfigurationManager::class);
             $monologFactory = LoggerFactory::getInstance();
             $loggerConfigurations = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Flowpack.Monolog');
             $monologFactory->injectConfiguration($loggerConfigurations);
         }
     });
 }
 /**
  * Make sure required paths and files are available outside of Package
  * Run on every Composer install or update - must be configured in root manifest
  *
  * @param CommandEvent $event
  * @return void
  */
 public static function postUpdateAndInstall(CommandEvent $event)
 {
     if (!defined('FLOW_PATH_ROOT')) {
         define('FLOW_PATH_ROOT', getcwd() . '/');
     }
     if (!defined('FLOW_PATH_PACKAGES')) {
         define('FLOW_PATH_PACKAGES', getcwd() . '/Packages/');
     }
     if (!defined('FLOW_PATH_CONFIGURATION')) {
         define('FLOW_PATH_CONFIGURATION', getcwd() . '/Configuration/');
     }
     Files::createDirectoryRecursively('Configuration');
     Files::createDirectoryRecursively('Data');
     Files::copyDirectoryRecursively('Packages/Framework/TYPO3.Flow/Resources/Private/Installer/Distribution/Essentials', './', false, true);
     Files::copyDirectoryRecursively('Packages/Framework/TYPO3.Flow/Resources/Private/Installer/Distribution/Defaults', './', true, true);
     $packageManager = new PackageManager();
     $packageManager->rescanPackages();
     chmod('flow', 0755);
 }
예제 #24
0
 /**
  * Sets up xhprof, some directories, the profiler and wires signals to slots.
  *
  * @param Bootstrap $bootstrap
  * @return void
  */
 public function boot(Bootstrap $bootstrap)
 {
     if (($samplingRate = getenv('PHPPROFILER_SAMPLINGRATE')) !== FALSE) {
         $currentSampleValue = mt_rand() / mt_getrandmax();
         if ($currentSampleValue > (double) $samplingRate) {
             return;
         }
     }
     $profiler = Profiler::getInstance();
     $profiler->setConfigurationProvider(function () use($bootstrap) {
         $settings = $bootstrap->getEarlyInstance('TYPO3\\Flow\\Configuration\\ConfigurationManager')->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Sandstorm.PhpProfiler');
         if (!file_exists($settings['plumber']['profilePath'])) {
             Files::createDirectoryRecursively($settings['plumber']['profilePath']);
         }
         return $settings;
     });
     $run = $profiler->start();
     $run->setOption('Context', (string) $bootstrap->getContext());
     $dispatcher = $bootstrap->getSignalSlotDispatcher();
     $this->connectToSignals($dispatcher, $profiler, $run, $bootstrap);
     $this->connectToNeosSignals($dispatcher, $profiler, $run, $bootstrap);
 }
 /**
  * @param Schema $schema
  * @return void
  */
 public function up(Schema $schema)
 {
     $this->abortIf($this->connection->getDatabasePlatform()->getName() != "postgresql");
     $resourcesResult = $this->connection->executeQuery('SELECT persistence_object_identifier, sha1, filename FROM typo3_flow_resource_resource');
     while ($resourceInfo = $resourcesResult->fetch(\PDO::FETCH_ASSOC)) {
         $resourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . wordwrap($resourceInfo['sha1'], 5, '/', true) . '/' . $resourceInfo['sha1'];
         $newResourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $resourceInfo['sha1'][0] . '/' . $resourceInfo['sha1'][1] . '/' . $resourceInfo['sha1'][2] . '/' . $resourceInfo['sha1'][3] . '/' . $resourceInfo['sha1'];
         if (!file_exists($newResourcePathAndFilename)) {
             if (!file_exists($resourcePathAndFilename)) {
                 $this->write(sprintf('<warning>Could not move the data file of resource "%s" from its legacy location at "%s" to the correct location "%s" because the source file does not exist.', $resourceInfo['sha1'], $resourcePathAndFilename, $newResourcePathAndFilename));
                 continue;
             }
             if (!file_exists(dirname($newResourcePathAndFilename))) {
                 Files::createDirectoryRecursively(dirname($newResourcePathAndFilename));
             }
             if (@rename($resourcePathAndFilename, $newResourcePathAndFilename) === false) {
                 $this->write(sprintf('<warning>Could not move the data file of resource "%s" from its legacy location at "%s" to the correct location "%s".', $resourceInfo['sha1'], $resourcePathAndFilename, $newResourcePathAndFilename));
             }
             Files::removeEmptyDirectoriesOnPath(dirname($resourcePathAndFilename));
         }
     }
 }
 /**
  * @param string $cssFile
  * @param string $outputExtension
  * @param string $path
  *
  * @throws \Exception
  * @throws \TYPO3\Flow\Utility\Exception
  */
 public function analyzeFontAweSomeCommand($cssFile, $outputExtension = '', $path = '')
 {
     if ($outputExtension !== null) {
         $pageTsFile = ExtensionManagementUtility::extPath($outputExtension) . 'Configuration/PageTS/themes.icons.pagets';
         $setupTsFile = ExtensionManagementUtility::extPath($outputExtension) . 'Configuration/TypoScript/Library/lib.icons.cssMap.setupts';
         Files::createDirectoryRecursively(dirname($pageTsFile));
         Files::createDirectoryRecursively(dirname($setupTsFile));
     } elseif (file_exists($path)) {
         $pageTsFile = $path . '/themes.icons.pagets';
         $setupTsFile = $path . '/lib.icons.cssMap.setupts';
     } else {
         throw new \Exception('Please specify either an extension or an path where to store the icon files' . $path);
     }
     if (!is_file($cssFile)) {
         throw new \Exception('CssFile not found');
     }
     $cssFileContent = file_get_contents($cssFile);
     $pattern = '#\\.(.*)-(.*):before#Ui';
     preg_match_all($pattern, $cssFileContent, $iconMatches);
     file_put_contents($pageTsFile, $this->renderContent(ExtensionManagementUtility::extPath('themes') . 'Resources/Private/Templates/ThemesCommand/PageTs.txt', $iconMatches[2], 'fa'));
     file_put_contents($setupTsFile, $this->renderContent(ExtensionManagementUtility::extPath('themes') . 'Resources/Private/Templates/ThemesCommand/SetupTs.txt', $iconMatches[2], 'fa'));
 }
 /**
  * Sets a reference to the cache frontend which uses this backend and
  * initializes the default cache directory.
  *
  * @param \TYPO3\Flow\Cache\Frontend\FrontendInterface $cache The cache frontend
  * @return void
  * @throws \TYPO3\Flow\Cache\Exception
  */
 public function setCache(FrontendInterface $cache)
 {
     parent::setCache($cache);
     $codeOrData = $cache instanceof PhpFrontend ? 'Code' : 'Data';
     $cacheDirectory = $this->cacheDirectory ?: $this->environment->getPathToTemporaryDirectory() . 'Cache/' . $codeOrData . '/' . $this->cacheIdentifier . '/';
     if (!is_writable($cacheDirectory)) {
         try {
             \TYPO3\Flow\Utility\Files::createDirectoryRecursively($cacheDirectory);
         } catch (\TYPO3\Flow\Utility\Exception $exception) {
             throw new \TYPO3\Flow\Cache\Exception('The cache directory "' . $cacheDirectory . '" could not be created.', 1264426237);
         }
     }
     if (!is_dir($cacheDirectory) && !is_link($cacheDirectory)) {
         throw new \TYPO3\Flow\Cache\Exception('The cache directory "' . $cacheDirectory . '" does not exist.', 1203965199);
     }
     if (!is_writable($cacheDirectory)) {
         throw new \TYPO3\Flow\Cache\Exception('The cache directory "' . $cacheDirectory . '" is not writable.', 1203965200);
     }
     $this->cacheDirectory = $cacheDirectory;
     $this->cacheEntryFileExtension = $cache instanceof PhpFrontend ? '.php' : '';
     if (strlen($this->cacheDirectory) + 23 > $this->environment->getMaximumPathLength()) {
         throw new \TYPO3\Flow\Cache\Exception('The length of the temporary cache path "' . $this->cacheDirectory . '" exceeds the maximum path length of ' . ($this->environment->getMaximumPathLength() - 23) . '. Please consider setting the temporaryDirectoryBase option to a shorter path. ', 1248710426);
     }
 }
 /**
  * Explicitly compile proxy classes
  *
  * The compile command triggers the proxy class compilation.
  * Although a compilation run is triggered automatically by Flow, there might
  * be cases in a production context where a manual compile run is needed.
  *
  * @Flow\Internal
  * @param boolean $force If set, classes will be compiled even though the cache says that everything is up to date.
  * @return void
  */
 public function compileCommand($force = false)
 {
     /** @var VariableFrontend $objectConfigurationCache */
     $objectConfigurationCache = $this->cacheManager->getCache('Flow_Object_Configuration');
     if ($force === false) {
         if ($objectConfigurationCache->has('allCompiledCodeUpToDate')) {
             return;
         }
     }
     /** @var PhpFrontend $classesCache */
     $classesCache = $this->cacheManager->getCache('Flow_Object_Classes');
     $this->proxyClassCompiler->injectClassesCache($classesCache);
     $this->aopProxyClassBuilder->injectObjectConfigurationCache($objectConfigurationCache);
     $this->aopProxyClassBuilder->build();
     $this->dependencyInjectionProxyClassBuilder->build();
     $classCount = $this->proxyClassCompiler->compile();
     $dataTemporaryPath = $this->environment->getPathToTemporaryDirectory();
     Files::createDirectoryRecursively($dataTemporaryPath);
     file_put_contents($dataTemporaryPath . 'AvailableProxyClasses.php', $this->proxyClassCompiler->getStoredProxyClassMap());
     $objectConfigurationCache->set('allCompiledCodeUpToDate', true);
     $classesCacheBackend = $classesCache->getBackend();
     if ($this->bootstrap->getContext()->isProduction() && $classesCacheBackend instanceof FreezableBackendInterface) {
         /** @var FreezableBackendInterface $backend */
         $backend = $classesCache->getBackend();
         $backend->freeze();
     }
     $this->emitFinishedCompilationRun($classCount);
 }
 /**
  * Applies all registered moveFile operations.
  *
  * @return void
  */
 protected function applyFileOperations()
 {
     foreach ($this->operations['moveFile'] as $operation) {
         $oldPath = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[0]));
         $newPath = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[1]));
         if (substr($oldPath, -1) === '*') {
             $oldPath = substr($oldPath, 0, -1);
             if (!file_exists($oldPath)) {
                 continue;
             }
             if (!file_exists($newPath)) {
                 Files::createDirectoryRecursively($newPath);
             }
             if (!is_dir($newPath)) {
                 continue;
             }
             foreach (Files::getRecursiveDirectoryGenerator($this->targetPackageData['path'], null, true) as $pathAndFilename) {
                 if (substr_compare($pathAndFilename, $oldPath, 0, strlen($oldPath)) === 0) {
                     $relativePathAndFilename = substr($pathAndFilename, strlen($oldPath));
                     if (!is_dir(dirname(Files::concatenatePaths(array($newPath, $relativePathAndFilename))))) {
                         Files::createDirectoryRecursively(dirname(Files::concatenatePaths(array($newPath, $relativePathAndFilename))));
                     }
                     Git::move($pathAndFilename, Files::concatenatePaths(array($newPath, $relativePathAndFilename)));
                 }
             }
         } else {
             $oldPath = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[0]));
             $newPath = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[1]));
             Git::move($oldPath, $newPath);
         }
     }
     foreach ($this->operations['deleteFile'] as $operation) {
         $filename = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[0]));
         if (file_exists($filename)) {
             Git::remove($filename);
         }
     }
 }
 /**
  * Moves a package from one path to another.
  *
  * @param string $fromAbsolutePath
  * @param string $toAbsolutePath
  * @return void
  */
 protected function movePackage($fromAbsolutePath, $toAbsolutePath)
 {
     Files::createDirectoryRecursively($toAbsolutePath);
     Files::copyDirectoryRecursively($fromAbsolutePath, $toAbsolutePath, false, true);
     Files::removeDirectoryRecursively($fromAbsolutePath);
 }