load() 공개 메소드

Loads the specified configuration file and returns its content as an array. If the file does not exist or could not be loaded, an empty array is returned
public load ( string $pathAndFilename, boolean $allowSplitSource = false ) : array
$pathAndFilename string Full path and filename of the file to load, excluding the file extension (ie. ".yaml")
$allowSplitSource boolean If TRUE, the type will be used as a prefix when looking for configuration files
리턴 array
 /**
  * Loads the specified configuration file and returns its content as an
  * array. If the file does not exist or could not be loaded, an empty
  * array is returned
  *
  * @param string $pathAndFilename Full path and filename of the file to load, excluding the file extension (ie. ".yaml")
  * @param boolean $allowSplitSource If TRUE, the type will be used as a prefix when looking for configuration files
  * @return array
  * @throws \Neos\Flow\Configuration\Exception\ParseErrorException
  */
 public function load($pathAndFilename, $allowSplitSource = false)
 {
     if (strpos($pathAndFilename, FLOW_PATH_CONFIGURATION) === 0) {
         return [];
     } else {
         return parent::load($pathAndFilename, $allowSplitSource);
     }
 }
 /**
  * Apply the given processor to the raw results of loading the given configuration
  * type for the package from YAML. If multiple files exist (context configuration)
  * all are processed independently.
  *
  * @param string $configurationType One of ConfigurationManager::CONFIGURATION_TYPE_*
  * @param \Closure $processor
  * @param boolean $saveResult
  * @return void
  */
 protected function processConfiguration($configurationType, \Closure $processor, $saveResult = false)
 {
     if (is_dir($this->targetPackageData['path'] . '/Configuration') === false) {
         return;
     }
     $yamlPathsAndFilenames = Files::readDirectoryRecursively($this->targetPackageData['path'] . '/Configuration', 'yaml', true);
     $configurationPathsAndFilenames = array_filter($yamlPathsAndFilenames, function ($pathAndFileName) use($configurationType) {
         if (strpos(basename($pathAndFileName, '.yaml'), $configurationType) === 0) {
             return true;
         } else {
             return false;
         }
     });
     $yamlSource = new YamlSource();
     foreach ($configurationPathsAndFilenames as $pathAndFilename) {
         $originalConfiguration = $configuration = $yamlSource->load(substr($pathAndFilename, 0, -5));
         $processor($configuration);
         if ($saveResult === true && $configuration !== $originalConfiguration) {
             $yamlSource->save(substr($pathAndFilename, 0, -5), $configuration);
         }
     }
 }
 /**
  * Loads specified sub routes and builds composite routes.
  *
  * @param array $routesConfiguration
  * @return void
  * @throws Exception\ParseErrorException
  * @throws Exception\RecursionException
  */
 protected function mergeRoutesWithSubRoutes(array &$routesConfiguration)
 {
     $mergedRoutesConfiguration = [];
     foreach ($routesConfiguration as $routeConfiguration) {
         if (!isset($routeConfiguration['subRoutes'])) {
             $mergedRoutesConfiguration[] = $routeConfiguration;
             continue;
         }
         $mergedSubRoutesConfiguration = [$routeConfiguration];
         foreach ($routeConfiguration['subRoutes'] as $subRouteKey => $subRouteOptions) {
             if (!isset($subRouteOptions['package'])) {
                 throw new Exception\ParseErrorException(sprintf('Missing package configuration for SubRoute in Route "%s".', isset($routeConfiguration['name']) ? $routeConfiguration['name'] : 'unnamed Route'), 1318414040);
             }
             if (!isset($this->packages[$subRouteOptions['package']])) {
                 throw new Exception\ParseErrorException(sprintf('The SubRoute Package "%s" referenced in Route "%s" is not available.', $subRouteOptions['package'], isset($routeConfiguration['name']) ? $routeConfiguration['name'] : 'unnamed Route'), 1318414040);
             }
             /** @var $package PackageInterface */
             $package = $this->packages[$subRouteOptions['package']];
             $subRouteFilename = 'Routes';
             if (isset($subRouteOptions['suffix'])) {
                 $subRouteFilename .= '.' . $subRouteOptions['suffix'];
             }
             $subRouteConfiguration = [];
             foreach (array_reverse($this->orderedListOfContextNames) as $contextName) {
                 $subRouteFilePathAndName = $package->getConfigurationPath() . $contextName . '/' . $subRouteFilename;
                 $subRouteConfiguration = array_merge($subRouteConfiguration, $this->configurationSource->load($subRouteFilePathAndName));
             }
             $subRouteFilePathAndName = $package->getConfigurationPath() . $subRouteFilename;
             $subRouteConfiguration = array_merge($subRouteConfiguration, $this->configurationSource->load($subRouteFilePathAndName));
             if ($this->subRoutesRecursionLevel > self::MAXIMUM_SUBROUTE_RECURSIONS) {
                 throw new Exception\RecursionException(sprintf('Recursion level of SubRoutes exceed ' . self::MAXIMUM_SUBROUTE_RECURSIONS . ', probably because of a circular reference. Last successfully loaded route configuration is "%s".', $subRouteFilePathAndName), 1361535753);
             }
             $this->subRoutesRecursionLevel++;
             $this->mergeRoutesWithSubRoutes($subRouteConfiguration);
             $this->subRoutesRecursionLevel--;
             $mergedSubRoutesConfiguration = $this->buildSubRouteConfigurations($mergedSubRoutesConfiguration, $subRouteConfiguration, $subRouteKey, $subRouteOptions);
         }
         $mergedRoutesConfiguration = array_merge($mergedRoutesConfiguration, $mergedSubRoutesConfiguration);
     }
     $routesConfiguration = $mergedRoutesConfiguration;
 }
 /**
  * @test
  */
 public function splitConfigurationFilesAreMergedAsExpected()
 {
     $expectedConfiguration = ['configurationFileHasBeenLoaded' => true, 'Neos' => ['Flow' => ['default' => 'test', 'toBeOverwritten' => 2, 'something' => 'zzz', '@bar' => 1, 'aboolean' => true]]];
     $pathAndFilename = __DIR__ . '/../Fixture/SplitYamlConfigurationFile';
     $configurationSource = new YamlSource();
     $configuration = $configurationSource->load($pathAndFilename, true);
     $this->assertSame($expectedConfiguration, $configuration);
 }
예제 #5
0
 /**
  * @return void
  */
 protected function initializeAction()
 {
     $this->distributionSettings = $this->configurationSource->load(FLOW_PATH_CONFIGURATION . \Neos\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS);
 }
예제 #6
0
 /**
  * Checks if the configured PHP binary is executable and the same version as the one
  * running the current (web server) PHP process. If not or if there is no binary configured,
  * tries to find the correct one on the PATH.
  *
  * Once found, the binary will be written to the configuration, if it is not the default one
  * (PHP_BINARY or in PHP_BINDIR).
  *
  * @return Message An error or warning message or NULL if PHP was detected successfully
  */
 protected function checkAndSetPhpBinaryIfNeeded()
 {
     $configurationSource = new YamlSource();
     $distributionSettings = $configurationSource->load(FLOW_PATH_CONFIGURATION . ConfigurationManager::CONFIGURATION_TYPE_SETTINGS);
     if (isset($distributionSettings['TYPO3']['Flow']['core']['phpBinaryPathAndFilename'])) {
         return $this->checkPhpBinary($distributionSettings['TYPO3']['Flow']['core']['phpBinaryPathAndFilename']);
     }
     list($phpBinaryPathAndFilename, $message) = $this->detectPhpBinaryPathAndFilename();
     if ($phpBinaryPathAndFilename !== null) {
         $defaultPhpBinaryPathAndFilename = PHP_BINDIR . '/php';
         if (DIRECTORY_SEPARATOR !== '/') {
             $defaultPhpBinaryPathAndFilename = str_replace('\\', '/', $defaultPhpBinaryPathAndFilename) . '.exe';
         }
         if ($phpBinaryPathAndFilename !== $defaultPhpBinaryPathAndFilename) {
             $distributionSettings = \Neos\Utility\Arrays::setValueByPath($distributionSettings, 'Neos.Flow.core.phpBinaryPathAndFilename', $phpBinaryPathAndFilename);
             $configurationSource->save(FLOW_PATH_CONFIGURATION . ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $distributionSettings);
         }
     }
     return $message;
 }