getActivePackages() 공개 메소드

A package is active, if it is available and has been activated in the package manager settings.
public getActivePackages ( ) : array
리턴 array
 public function initializeObject($reason)
 {
     if ($reason === ObjectManagerInterface::INITIALIZATIONCAUSE_RECREATED) {
         return;
     }
     /** @var Package $package */
     foreach ($this->packageManager->getActivePackages() as $package) {
         foreach ($package->getNamespaces() as $namespace) {
             $this->addNamespace(strtolower($package->getPackageKey()), $namespace . '\\ViewHelpers');
         }
     }
 }
예제 #2
0
 /**
  * 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('Neos.Flow');
     $version = $flowPackage->getInstalledVersion();
     $this->view->assign('version', $version);
     $activePackages = $this->packageManager->getActivePackages();
     $this->view->assign('activePackages', $activePackages);
     $this->view->assign('notDevelopmentContext', !$this->objectManager->getContext()->isDevelopment());
 }
 /**
  * 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 neos.flow:cache:warmup
  * @see neos.flow:package:freeze
  * @see neos.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 = [];
     foreach (array_keys($this->packageManager->getActivePackages()) as $packageKey) {
         if ($this->packageManager->isPackageFrozen($packageKey)) {
             $frozenPackages[] = $packageKey;
         }
     }
     if ($frozenPackages !== []) {
         $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, [], 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, [$frozenPackages]);
     }
     $this->sendAndExit(0);
 }
예제 #4
0
 /**
  * Return the configuration needed for Migrations.
  *
  * @return Configuration
  */
 protected function getMigrationConfiguration()
 {
     $this->output = [];
     $that = $this;
     $outputWriter = new OutputWriter(function ($message) use($that) {
         $that->output[] = $message;
     });
     /** @var \Doctrine\DBAL\Connection $connection */
     $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 Configuration($connection, $outputWriter);
     $configuration->setMigrationsNamespace(\Neos\Flow\Persistence\Doctrine\Migrations::class);
     $configuration->setMigrationsDirectory(Files::concatenatePaths([FLOW_PATH_DATA, 'DoctrineMigrations']));
     $configuration->setMigrationsTableName(self::DOCTRINE_MIGRATIONSTABLENAME);
     $configuration->createMigrationTable();
     $databasePlatformName = $this->getDatabasePlatformName();
     /** @var PackageInterface $package */
     foreach ($this->packageManager->getActivePackages() as $package) {
         $path = Files::concatenatePaths([$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 = [];
     $packages = $this->packageManager->getActivePackages();
     foreach ($packages as $packageKey => $package) {
         /** @var PackageInterface $package */
         $publicResourcesPath = Files::concatenatePaths([$package->getResourcesPath(), 'Public']);
         if (is_dir($publicResourcesPath)) {
             $paths[$packageKey] = $publicResourcesPath;
         }
     }
     return $paths;
 }
 /**
  * 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 \Neos\Error\Messages\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 = [];
     $activePackages = $this->packageManager->getActivePackages();
     foreach ($activePackages as $package) {
         $packageKey = $package->getPackageKey();
         $packageSchemaPath = Files::concatenatePaths([$package->getResourcesPath(), 'Private/Schema']);
         if (is_dir($packageSchemaPath)) {
             foreach (Files::getRecursiveDirectoryGenerator($packageSchemaPath, '.schema.yaml') 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[] = ['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 = Arrays::getValueByPath($configuration, $schemaFileInfo['path']);
         } else {
             $data = $configuration;
         }
         if (empty($data)) {
             $result->addNotice(new Notice('No configuration found, skipping schema "%s".', 1364985445, [substr($schemaFileInfo['file'], strlen(FLOW_PATH_ROOT))]));
         } else {
             $parsedSchema = 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;
 }
예제 #7
0
 /**
  * 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([$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);
             }
         }
     }
 }
 /**
  * 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 neos.flow:package:unfreeze
  * @see neos.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]);
     }
 }
예제 #9
0
 /**
  * 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) {
             $autoIncludeTypoScriptFile = sprintf($this->autoIncludeTypoScriptPattern, $packageKey);
             if (is_file($autoIncludeTypoScriptFile)) {
                 $autoIncludeTypoScript[] = $autoIncludeTypoScriptFile;
             } else {
                 // If there is no Root.fusion found in the default path pattern or the legacy path pattern
                 // use the default path pattern so an exception will show the correct path pattern and not a
                 // legacy path pattern
                 $legacyAutoIncludeTypoScriptFile = sprintf($this->legacyAutoIncludeTypoScriptPattern, $packageKey);
                 if (is_file($legacyAutoIncludeTypoScriptFile)) {
                     $autoIncludeTypoScript[] = $legacyAutoIncludeTypoScriptFile;
                 } else {
                     $autoIncludeTypoScript[] = $autoIncludeTypoScriptFile;
                 }
             }
         }
     }
     return $autoIncludeTypoScript;
 }
예제 #10
0
 /**
  * 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} = 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) {
             $autoIncludeTypoScriptFile = sprintf($this->autoIncludeTypoScriptPattern, $packageKey);
             if (is_file($autoIncludeTypoScriptFile)) {
                 $autoIncludeTypoScript[] = $autoIncludeTypoScriptFile;
             } else {
                 $autoIncludeTypoScript[] = sprintf($this->legacyAutoIncludeTypoScriptPattern, $packageKey);
             }
         }
     }
     return $autoIncludeTypoScript;
 }