/** * Creates a Doctrine ODM DocumentManager * * @return \Doctrine\ODM\CouchDB\DocumentManager */ public function create() { if (isset($this->documentManager)) { return $this->documentManager; } $httpClient = new \Doctrine\CouchDB\HTTP\SocketClient($this->settings['host'], $this->settings['port'], $this->settings['username'], $this->settings['password'], $this->settings['ip']); $reader = new \Doctrine\Common\Annotations\AnnotationReader(); $metaDriver = new \Doctrine\ODM\CouchDB\Mapping\Driver\AnnotationDriver($reader); $config = new \Doctrine\ODM\CouchDB\Configuration(); $config->setMetadataDriverImpl($metaDriver); $packages = $this->packageManager->getActivePackages(); foreach ($packages as $package) { $designDocumentRootPath = \TYPO3\Flow\Utility\Files::concatenatePaths(array($package->getPackagePath(), 'Migrations/CouchDB/DesignDocuments')); if (is_dir($designDocumentRootPath)) { $packageDesignDocumentFolders = glob($designDocumentRootPath . '/*'); foreach ($packageDesignDocumentFolders as $packageDesignDocumentFolder) { if (is_dir($packageDesignDocumentFolder)) { $designDocumentName = strtolower(basename($packageDesignDocumentFolder)); $config->addDesignDocument($designDocumentName, 'Radmiraal\\CouchDB\\View\\Migration', array('packageKey' => $package->getPackageKey(), 'path' => $packageDesignDocumentFolder)); } } } } $proxyDirectory = \TYPO3\Flow\Utility\Files::concatenatePaths(array($this->environment->getPathToTemporaryDirectory(), 'DoctrineODM/Proxies')); \TYPO3\Flow\Utility\Files::createDirectoryRecursively($proxyDirectory); $config->setProxyDir($proxyDirectory); $config->setProxyNamespace('TYPO3\\Flow\\Persistence\\DoctrineODM\\Proxies'); $config->setAutoGenerateProxyClasses(TRUE); $couchClient = new \Doctrine\CouchDB\CouchDBClient($httpClient, $this->settings['databaseName']); $this->documentManager = \Doctrine\ODM\CouchDB\DocumentManager::create($couchClient, $config); return $this->documentManager; }
/** * @param string $packageName * @return bool */ protected function isPackageActiveByName($packageName) { $foundPackage = false; foreach ($this->packageManager->getActivePackages() as $key => $package) { if (property_exists($package->getComposerManifest(), 'name') == true && $package->getComposerManifest()->name == $packageName) { $foundPackage = true; break; } } return $foundPackage; }
/** * Convert (and optionally filter) code coverage data generated by functional tests, * such that file references inside point not to the code cache inside Data/Temporary/...., * but to the Classes/ directory of the packages. * * <b>Example Usage:</b> * phpunit -c Build/BuildEssentials/FunctionalTests.xml --coverage-php Build/Reports/RawFunctionalTestCoverageReport.php * ./flow codeCoverage:convert Build/Reports/RawFunctionalTestCoverageReport.php Build/Reports/FunctionalTestCoverageReport.php --packages 'Your.Packages,Separated.By.Comma' * * The "--packages" argument is optional; but using it results in a huge speed boost; * as only the classes from the specified packages are included in the coverage result. * * @param string $codeCoverageFile Path to the code coverage file generated with "--coverage-php" of phpunit. * @param string $outFile Path to the converted code coverage file * @param string $packages The comma-separated list of packages to filter for. These packages must be installed here. * @param string $context The Flow context which has been used during the functional test run. Only needs to be modified if tests are ran in a special context. */ public function convertCommand($codeCoverageFile, $outFile, $packages = '*', $context = 'Testing') { // Load $packages which should be taken into account while conversion $packageKeys = $packages; if ($packageKeys === '*') { $packages = $this->packageManager->getActivePackages(); } else { $packages = array(); foreach (\TYPO3\Flow\Utility\Arrays::trimExplode(',', $packageKeys) as $packageKey) { $packages[] = $this->packageManager->getPackage($packageKey); } } // For all $packages which should be used, build up a "cache-file-name" -> "real-file-name" mapping. $reverseIndexOfCacheFileNamesToClassFiles = array(); foreach ($packages as $package) { /* @var $package \TYPO3\Flow\Package\PackageInterface */ foreach ($package->getClassFiles() as $className => $fileName) { $cacheFileName = str_replace('\\', '_', $className); $reverseIndexOfCacheFileNamesToClassFiles[$cacheFileName] = $package->getPackagePath() . $fileName; } } // Modify the coverage report /* @var $coverage \Php_CodeCoverage */ $coverage = unserialize(file_get_contents($codeCoverageFile)); $coverageData = $coverage->getData(); $baseDirectoryLength = strlen(FLOW_PATH_ROOT . 'Data/Temporary/' . $context . '/Cache/Code/Flow_Object_Classes/'); $adjustedCoverageData = array(); foreach ($coverageData as $fullCacheFileName => $coverageDataForFile) { $shortCacheFileName = substr($fullCacheFileName, $baseDirectoryLength, -4); if (isset($reverseIndexOfCacheFileNamesToClassFiles[$shortCacheFileName])) { $classFileInPackage = $reverseIndexOfCacheFileNamesToClassFiles[$shortCacheFileName]; $numberOfLinesOfFile = count(file($classFileInPackage)); if (isset($adjustedCoverageData[$classFileInPackage])) { throw new \Sandstorm\Fuzzer\Exception('Coverage data already found for class file "' . $classFileInPackage . '". This should never happen; so we do not override it. It is probably a bug in Fuzzer.', 1367238729); } $adjustedCoverageData[$classFileInPackage] = array(); foreach ($coverageDataForFile as $lineNumber => $coveredBy) { if ($lineNumber <= $numberOfLinesOfFile) { $adjustedCoverageData[$classFileInPackage][$lineNumber] = $coveredBy; } } } } // Save the new coverage report $adjustedCoverage = new PhpunitCodeCoverage(); $adjustedCoverage->setData($adjustedCoverageData); $adjustedCoverage->setTests($coverage->getTests()); file_put_contents($outFile, serialize($adjustedCoverage)); }
/** * Index action * * @return void */ public function indexAction() { $this->view->assign('flowPathRoot', realpath(FLOW_PATH_ROOT)); $this->view->assign('flowPathWeb', realpath(FLOW_PATH_WEB)); $this->view->assign('isMyPackageActive', $this->packageManager->isPackageActive('MyCompany.MyPackage')); $baseUri = $this->request->getHttpRequest()->getBaseUri(); $this->view->assign('baseUri', $baseUri); $this->view->assign('isWindows', DIRECTORY_SEPARATOR !== '/'); $flowPackage = $this->packageManager->getPackage('TYPO3.Flow'); $version = $flowPackage->getPackageMetaData()->getVersion(); $this->view->assign('version', $version); $activePackages = $this->packageManager->getActivePackages(); $this->view->assign('activePackages', $activePackages); $this->view->assign('notDevelopmentContext', !$this->objectManager->getContext()->isDevelopment()); }
/** * Finds all Locale objects representing locales available in the * Flow installation. This is done by scanning all Private and Public * resource files of all active packages, in order to find localized files. * * Localized files have a locale identifier added before their extension * (or at the end of filename, if no extension exists). For example, a * localized file for foobar.png, can be foobar.en.png, fobar.en_GB.png, etc. * * Just one localized resource file causes the corresponding locale to be * regarded as available (installed, supported). * * Note: result of this method invocation is cached * * @return void */ protected function generateAvailableLocalesCollectionByScanningFilesystem() { /** @var PackageInterface $activePackage */ foreach ($this->packageManager->getActivePackages() as $activePackage) { $packageResourcesPath = $activePackage->getResourcesPath(); if (!is_dir($packageResourcesPath)) { continue; } $directories = array(Files::getNormalizedPath($packageResourcesPath)); while ($directories !== array()) { $currentDirectory = array_pop($directories); if ($handle = opendir($currentDirectory)) { while (false !== ($filename = readdir($handle))) { if ($filename[0] === '.') { continue; } $pathAndFilename = Files::concatenatePaths(array($currentDirectory, $filename)); if (is_dir($pathAndFilename)) { array_push($directories, Files::getNormalizedPath($pathAndFilename)); } else { $localeIdentifier = Utility::extractLocaleTagFromFilename($filename); if ($localeIdentifier !== false) { $this->localeCollection->addLocale(new Locale($localeIdentifier)); } } } closedir($handle); } } } }
/** * Flush all caches * * The flush command flushes all caches (including code caches) which have been * registered with Flow's Cache Manager. It also removes any session data. * * If fatal errors caused by a package prevent the compile time bootstrap * from running, the removal of any temporary data can be forced by specifying * the option <b>--force</b>. * * This command does not remove the precompiled data provided by frozen * packages unless the <b>--force</b> option is used. * * @param boolean $force Force flushing of any temporary data * @return void * @see typo3.flow:cache:warmup * @see typo3.flow:package:freeze * @see typo3.flow:package:refreeze */ public function flushCommand($force = false) { // Internal note: the $force option is evaluated early in the Flow // bootstrap in order to reliably flush the temporary data before any // other code can cause fatal errors. $this->cacheManager->flushCaches(); $this->outputLine('Flushed all caches for "' . $this->bootstrap->getContext() . '" context.'); if ($this->lockManager->isSiteLocked()) { $this->lockManager->unlockSite(); } $frozenPackages = array(); foreach (array_keys($this->packageManager->getActivePackages()) as $packageKey) { if ($this->packageManager->isPackageFrozen($packageKey)) { $frozenPackages[] = $packageKey; } } if ($frozenPackages !== array()) { $this->outputFormatted(PHP_EOL . 'Please note that the following package' . (count($frozenPackages) === 1 ? ' is' : 's are') . ' currently frozen: ' . PHP_EOL); $this->outputFormatted(implode(PHP_EOL, $frozenPackages) . PHP_EOL, array(), 2); $message = 'As code and configuration changes in these packages are not detected, the application may respond '; $message .= 'unexpectedly if modifications were done anyway or the remaining code relies on these changes.' . PHP_EOL . PHP_EOL; $message .= 'You may call <b>package:refreeze all</b> in order to refresh frozen packages or use the <b>--force</b> '; $message .= 'option of this <b>cache:flush</b> command to flush caches if Flow becomes unresponsive.' . PHP_EOL; $this->outputFormatted($message, array($frozenPackages)); } $this->sendAndExit(0); }
/** * Return the configuration needed for Migrations. * * @return \Doctrine\DBAL\Migrations\Configuration\Configuration */ protected function getMigrationConfiguration() { $this->output = array(); $that = $this; $outputWriter = new \Doctrine\DBAL\Migrations\OutputWriter(function ($message) use($that) { $that->output[] = $message; }); $connection = $this->entityManager->getConnection(); $schemaManager = $connection->getSchemaManager(); if ($schemaManager->tablesExist(array('flow3_doctrine_migrationstatus')) === true) { $schemaManager->renameTable('flow3_doctrine_migrationstatus', self::DOCTRINE_MIGRATIONSTABLENAME); } $configuration = new \Doctrine\DBAL\Migrations\Configuration\Configuration($connection, $outputWriter); $configuration->setMigrationsNamespace('TYPO3\\Flow\\Persistence\\Doctrine\\Migrations'); $configuration->setMigrationsDirectory(\TYPO3\Flow\Utility\Files::concatenatePaths(array(FLOW_PATH_DATA, 'DoctrineMigrations'))); $configuration->setMigrationsTableName(self::DOCTRINE_MIGRATIONSTABLENAME); $configuration->createMigrationTable(); $databasePlatformName = $this->getDatabasePlatformName(); foreach ($this->packageManager->getActivePackages() as $package) { $path = \TYPO3\Flow\Utility\Files::concatenatePaths(array($package->getPackagePath(), 'Migrations', $databasePlatformName)); if (is_dir($path)) { $configuration->registerMigrationsFromDirectory($path); } } return $configuration; }
/** * Return the configuration needed for Migrations. * * @return \Doctrine\DBAL\Migrations\Configuration\Configuration */ protected function getMigrationConfiguration() { $this->output = array(); $that = $this; $outputWriter = new \Doctrine\DBAL\Migrations\OutputWriter(function ($message) use($that) { $that->output[] = $message; }); $connection = $this->entityManager->getConnection(); if ($connection->getSchemaManager()->tablesExist(array('flow3_doctrine_migrationstatus')) === TRUE) { // works for SQLite, MySQL, PostgreSQL, Oracle // does not work for SQL Server $connection->exec('ALTER TABLE flow3_doctrine_migrationstatus RENAME TO flow_doctrine_migrationstatus'); } $configuration = new \Doctrine\DBAL\Migrations\Configuration\Configuration($connection, $outputWriter); $configuration->setMigrationsNamespace('TYPO3\\Flow\\Persistence\\Doctrine\\Migrations'); $configuration->setMigrationsDirectory(\TYPO3\Flow\Utility\Files::concatenatePaths(array(FLOW_PATH_DATA, 'DoctrineMigrations'))); $configuration->setMigrationsTableName('flow_doctrine_migrationstatus'); $configuration->createMigrationTable(); $databasePlatformName = $this->getDatabasePlatformName(); foreach ($this->packageManager->getActivePackages() as $package) { $path = \TYPO3\Flow\Utility\Files::concatenatePaths(array($package->getPackagePath(), 'Migrations', $databasePlatformName)); if (is_dir($path)) { $configuration->registerMigrationsFromDirectory($path); } } return $configuration; }
/** * Returns the absolute paths of public resources directories of all active packages. * This method is used directly by the FileSystemSymlinkTarget. * * @return array<string> */ public function getPublicResourcePaths() { $paths = array(); $packages = $this->packageManager->getActivePackages(); foreach ($packages as $packageKey => $package) { /** @var PackageInterface $package */ $publicResourcesPath = Files::concatenatePaths(array($package->getResourcesPath(), 'Public')); if (is_dir($publicResourcesPath)) { $paths[$packageKey] = $publicResourcesPath; } } return $paths; }
/** * Returns an array of packages that are available for translation. * * The list includes basically every active package * - minus the ones that are excluded in the configuration * - minus the ones that don't have the needed translation files * * @return array all the available packages */ protected function getAvailablePackages() { $allPackages = $this->packageManager->getActivePackages(); // make sure the packages of the framework are excluded depending on our settings $packages = array(); $packagesToExclude = \TYPO3\Flow\Utility\Arrays::trimExplode(',', $this->settings['packagesToExclude']); foreach ($allPackages as $package) { if (!in_array($package->getPackageKey(), $packagesToExclude) && $this->hasXliffFilesInDefaultDirectories($package)) { $packages[] = $package; } } return $packages; }
/** * Validate a single configuration type * * @param string $configurationType the configuration typr to validate * @param string $path configuration path to validate, or NULL. * @param array $loadedSchemaFiles will be filled with a list of loaded schema files * @return \TYPO3\Flow\Error\Result * @throws Exception\SchemaValidationException */ protected function validateSingleType($configurationType, $path, &$loadedSchemaFiles) { $availableConfigurationTypes = $this->configurationManager->getAvailableConfigurationTypes(); if (in_array($configurationType, $availableConfigurationTypes) === FALSE) { throw new Exception\SchemaValidationException('The configuration type "' . $configurationType . '" was not found. Only the following configuration types are supported: "' . implode('", "', $availableConfigurationTypes) . '"', 1364984886); } $configuration = $this->configurationManager->getConfiguration($configurationType); // find schema files for the given type and path $schemaFileInfos = array(); $activePackages = $this->packageManager->getActivePackages(); foreach ($activePackages as $package) { $packageKey = $package->getPackageKey(); $packageSchemaPath = \TYPO3\Flow\Utility\Files::concatenatePaths(array($package->getResourcesPath(), 'Private/Schema')); if (is_dir($packageSchemaPath)) { $packageSchemaFiles = \TYPO3\Flow\Utility\Files::readDirectoryRecursively($packageSchemaPath, '.schema.yaml'); foreach ($packageSchemaFiles as $schemaFile) { $schemaName = substr($schemaFile, strlen($packageSchemaPath) + 1, -strlen('.schema.yaml')); $schemaNameParts = explode('.', str_replace('/', '.', $schemaName), 2); $schemaType = $schemaNameParts[0]; $schemaPath = isset($schemaNameParts[1]) ? $schemaNameParts[1] : NULL; if ($schemaType === $configurationType && ($path === NULL || strpos($schemaPath, $path) === 0)) { $schemaFileInfos[] = array('file' => $schemaFile, 'name' => $schemaName, 'path' => $schemaPath, 'packageKey' => $packageKey); } } } } if (count($schemaFileInfos) === 0) { throw new Exception\SchemaValidationException('No schema files found for configuration type "' . $configurationType . '"' . ($path !== NULL ? ' and path "' . $path . '".' : '.'), 1364985056); } $result = new Result(); foreach ($schemaFileInfos as $schemaFileInfo) { $loadedSchemaFiles[] = $schemaFileInfo['file']; if ($schemaFileInfo['path'] !== NULL) { $data = \TYPO3\Flow\Utility\Arrays::getValueByPath($configuration, $schemaFileInfo['path']); } else { $data = $configuration; } if (empty($data)) { $result->addNotice(new Notice('No configuration found, skipping schema "%s".', 1364985445, array(substr($schemaFileInfo['file'], strlen(FLOW_PATH_ROOT))))); } else { $parsedSchema = \Symfony\Component\Yaml\Yaml::parse($schemaFileInfo['file']); $validationResultForSingleSchema = $this->schemaValidator->validate($data, $parsedSchema); if ($schemaFileInfo['path'] !== NULL) { $result->forProperty($schemaFileInfo['path'])->merge($validationResultForSingleSchema); } else { $result->merge($validationResultForSingleSchema); } } } return $result; }
/** * Loads a list of available versions into an array. * * @return array * @throws \TYPO3\TYPO3CR\Migration\Exception\MigrationException */ protected function registerAvailableVersions() { $this->availableVersions = array(); foreach ($this->packageManager->getActivePackages() as $package) { $possibleMigrationsPath = \TYPO3\Flow\Utility\Files::concatenatePaths(array($package->getPackagePath(), 'Migrations/TYPO3CR')); if (!is_dir($possibleMigrationsPath)) { continue; } $directoryIterator = new \DirectoryIterator($possibleMigrationsPath); foreach ($directoryIterator as $fileInfo) { $filename = $fileInfo->getFilename(); if ($fileInfo->isFile() && $filename[0] !== '.' && substr($filename, -5) === '.yaml') { $versionFile = Files::getUnixStylePath($fileInfo->getPathname()); $versionNumber = substr(substr($filename, 7), 0, -5); if (array_key_exists($versionNumber, $this->availableVersions)) { throw new \TYPO3\TYPO3CR\Migration\Exception\MigrationException('The migration version ' . $versionNumber . ' exists twice, that is not supported.', 1345823182); } $this->availableVersions[$versionNumber] = array('filePathAndName' => $versionFile, 'package' => $package, 'formattedVersionNumber' => $versionNumber[6] . $versionNumber[7] . '-' . $versionNumber[4] . $versionNumber[5] . '-' . $versionNumber[0] . $versionNumber[1] . $versionNumber[2] . $versionNumber[3] . ' ' . $versionNumber[8] . $versionNumber[9] . ':' . $versionNumber[10] . $versionNumber[11] . ':' . $versionNumber[12] . $versionNumber[13]); } } } ksort($this->availableVersions); }
/** * Finds all Locale objects representing locales available in the * Flow installation. This is done by scanning all Private and Public * resource files of all active packages, in order to find localized files. * * Localized files have a locale identifier added before their extension * (or at the end of filename, if no extension exists). For example, a * localized file for foobar.png, can be foobar.en.png, fobar.en_GB.png, etc. * * Just one localized resource file causes the corresponding locale to be * regarded as available (installed, supported). * * Note: result of this method invocation is cached * * @return void */ protected function generateAvailableLocalesCollectionByScanningFilesystem() { $whitelistPaths = array_keys(array_filter((array) $this->settings['scan']['includePaths'])); if ($whitelistPaths === []) { return; } $blacklistPattern = $this->getScanBlacklistPattern(); /** @var PackageInterface $activePackage */ foreach ($this->packageManager->getActivePackages() as $activePackage) { $packageResourcesPath = Files::getNormalizedPath($activePackage->getResourcesPath()); if (!is_dir($packageResourcesPath)) { continue; } $directories = []; foreach ($whitelistPaths as $path) { $scanPath = Files::concatenatePaths(array($packageResourcesPath, $path)); if (is_dir($scanPath)) { array_push($directories, Files::getNormalizedPath($scanPath)); } } while ($directories !== []) { $currentDirectory = array_pop($directories); $relativeDirectory = '/' . str_replace($packageResourcesPath, '', $currentDirectory); if ($blacklistPattern !== '' && preg_match($blacklistPattern, $relativeDirectory) === 1) { continue; } if ($handle = opendir($currentDirectory)) { while (false !== ($filename = readdir($handle))) { if ($filename[0] === '.') { continue; } $pathAndFilename = Files::concatenatePaths(array($currentDirectory, $filename)); if (is_dir($pathAndFilename)) { array_push($directories, Files::getNormalizedPath($pathAndFilename)); } else { $localeIdentifier = Utility::extractLocaleTagFromFilename($filename); if ($localeIdentifier !== false) { $this->localeCollection->addLocale(new Locale($localeIdentifier)); } } } closedir($handle); } } } }
/** * Finds all Locale objects representing locales available in the * Flow installation. This is done by scanning all Private and Public * resource files of all active packages, in order to find localized files. * * Localized files have a locale identifier added before their extension * (or at the end of filename, if no extension exists). For example, a * localized file for foobar.png, can be foobar.en.png, fobar.en_GB.png, etc. * * Just one localized resource file causes the corresponding locale to be * regarded as available (installed, supported). * * Note: result of this method invocation is cached * * @return void */ protected function generateAvailableLocalesCollectionByScanningFilesystem() { foreach ($this->packageManager->getActivePackages() as $activePackage) { $packageResourcesPath = $this->localeBasePath . $activePackage->getPackageKey() . '/'; if (!is_dir($packageResourcesPath)) { continue; } $directoryIterator = new \RecursiveDirectoryIterator($packageResourcesPath, \RecursiveDirectoryIterator::UNIX_PATHS); $recursiveIteratorIterator = new \RecursiveIteratorIterator($directoryIterator, \RecursiveIteratorIterator::SELF_FIRST); foreach ($recursiveIteratorIterator as $fileOrDirectory) { if ($fileOrDirectory->isFile()) { $localeIdentifier = Utility::extractLocaleTagFromFilename($fileOrDirectory->getFilename()); if ($localeIdentifier !== FALSE) { $this->localeCollection->addLocale(new Locale($localeIdentifier)); } } } } }
/** * Freeze a package * * This function marks a package as <b>frozen</b> in order to improve performance * in a development context. While a package is frozen, any modification of files * within that package won't be tracked and can lead to unexpected behavior. * * File monitoring won't consider the given package. Further more, reflection * data for classes contained in the package is cached persistently and loaded * directly on the first request after caches have been flushed. The precompiled * reflection data is stored in the <b>Configuration</b> directory of the * respective package. * * By specifying <b>all</b> as a package key, all currently frozen packages are * frozen (the default). * * @param string $packageKey Key of the package to freeze * @return void * @see typo3.flow:package:unfreeze * @see typo3.flow:package:refreeze */ public function freezeCommand($packageKey = 'all') { if (!$this->bootstrap->getContext()->isDevelopment()) { $this->outputLine('Package freezing is only supported in Development context.'); $this->quit(3); } $packagesToFreeze = []; if ($packageKey === 'all') { foreach (array_keys($this->packageManager->getActivePackages()) as $packageKey) { if (!$this->packageManager->isPackageFrozen($packageKey)) { $packagesToFreeze[] = $packageKey; } } if ($packagesToFreeze === []) { $this->outputLine('Nothing to do, all active packages were already frozen.'); $this->quit(0); } } elseif ($packageKey === 'blackberry') { $this->outputLine('http://bit.ly/freeze-blackberry'); $this->quit(42); } else { if (!$this->packageManager->isPackageActive($packageKey)) { if ($this->packageManager->isPackageAvailable($packageKey)) { $this->outputLine('Package "%s" is not active and thus cannot be frozen.', [$packageKey]); $this->quit(1); } else { $this->outputLine('Package "%s" is not available.', [$packageKey]); $this->quit(2); } } if ($this->packageManager->isPackageFrozen($packageKey)) { $this->outputLine('Package "%s" was already frozen.', [$packageKey]); $this->quit(0); } $packagesToFreeze = [$packageKey]; } foreach ($packagesToFreeze as $packageKey) { $this->packageManager->freezePackage($packageKey); $this->outputLine('Froze package "%s".', [$packageKey]); } }
/** * Tries to load the reflection data from the compile time cache. * * The compile time cache is only supported for Development context and thus * this function will return in any other context. * * If no reflection data was found, this method will at least load the precompiled * reflection data of any possible frozen package. Even if precompiled reflection * data could be loaded, FALSE will be returned in order to signal that other * packages still need to be reflected. * * @return boolean TRUE if reflection data could be loaded, otherwise FALSE */ protected function loadClassReflectionCompiletimeCache() { $data = $this->reflectionDataCompiletimeCache->get('ReflectionData'); if ($data !== false) { foreach ($data as $propertyName => $propertyValue) { $this->{$propertyName} = $propertyValue; } return true; } if (!$this->context->isDevelopment()) { return false; } $useIgBinary = extension_loaded('igbinary'); foreach ($this->packageManager->getActivePackages() as $packageKey => $package) { if (!$this->packageManager->isPackageFrozen($packageKey)) { continue; } $pathAndFilename = $this->getPrecompiledReflectionStoragePath() . $packageKey . '.dat'; if (!file_exists($pathAndFilename)) { continue; } $data = $useIgBinary ? igbinary_unserialize(file_get_contents($pathAndFilename)) : unserialize(file_get_contents($pathAndFilename)); foreach ($data as $propertyName => $propertyValue) { $this->{$propertyName} = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($this->{$propertyName}, $propertyValue); } } return false; }
/** * Prepares an array with TypoScript paths to auto include before the Site TypoScript. * * @return array */ protected function prepareAutoIncludeTypoScript() { $autoIncludeTypoScript = array(); foreach (array_keys($this->packageManager->getActivePackages()) as $packageKey) { if (isset($this->autoIncludeConfiguration[$packageKey]) && $this->autoIncludeConfiguration[$packageKey] === true) { $autoIncludeTypoScript[] = sprintf($this->autoIncludeTypoScriptPattern, $packageKey); } } return $autoIncludeTypoScript; }
/** * Initialize action */ public function initializeAction() { $this->availablePackages = $this->packageManager->getAvailablePackages(); $this->activePackages = $this->packageManager->getActivePackages(); }