/**
  * 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);
     }
 }
Exemplo n.º 2
0
 /**
  * This method is called when the form of this step has been submitted
  *
  * @param array $formValues
  * @return void
  * @throws \Exception
  */
 public function postProcessFormValues(array $formValues)
 {
     $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Neos.Flow.persistence.backendOptions.driver', $formValues['driver']);
     $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Neos.Flow.persistence.backendOptions.dbname', $formValues['dbname']);
     $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Neos.Flow.persistence.backendOptions.user', $formValues['user']);
     $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Neos.Flow.persistence.backendOptions.password', $formValues['password']);
     $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Neos.Flow.persistence.backendOptions.host', $formValues['host']);
     $this->configurationSource->save(FLOW_PATH_CONFIGURATION . ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $this->distributionSettings);
     $this->configurationManager->flushConfigurationCache();
     $settings = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow');
     $connectionSettings = $settings['persistence']['backendOptions'];
     try {
         $this->connectToDatabase($connectionSettings);
     } catch (\Exception $exception) {
         if (!$exception instanceof DBALException && !$exception instanceof \PDOException) {
             throw $exception;
         }
         try {
             $this->createDatabase($connectionSettings, $formValues['dbname']);
         } catch (DBALException $exception) {
             throw new SetupException(sprintf('Database "%s" could not be created. Please check the permissions for user "%s". DBAL Exception: "%s"', $formValues['dbname'], $formValues['user'], $exception->getMessage()), 1351000841, $exception);
         } catch (\PDOException $exception) {
             throw new SetupException(sprintf('Database "%s" could not be created. Please check the permissions for user "%s". PDO Exception: "%s"', $formValues['dbname'], $formValues['user'], $exception->getMessage()), 1346758663, $exception);
         }
         try {
             $this->connectToDatabase($connectionSettings);
         } catch (DBALException $exception) {
             throw new SetupException(sprintf('Could not connect to database "%s". Please check the permissions for user "%s". DBAL Exception: "%s"', $formValues['dbname'], $formValues['user'], $exception->getMessage()), 1351000864);
         } catch (\PDOException $exception) {
             throw new SetupException(sprintf('Could not connect to database "%s". Please check the permissions for user "%s". PDO Exception: "%s"', $formValues['dbname'], $formValues['user'], $exception->getMessage()), 1346758737);
         }
     }
     $migrationExecuted = Scripts::executeCommand('neos.flow:doctrine:migrate', $settings, false);
     if ($migrationExecuted !== true) {
         throw new SetupException(sprintf('Could not execute database migrations. Please check the permissions for user "%s" and execute "./flow neos.flow:doctrine:migrate" manually.', $formValues['user']), 1346759486);
     }
     $this->resetPolicyRolesCacheAfterDatabaseChanges();
 }
 /**
  * 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);
 }
Exemplo n.º 6
0
 /**
  * @return void
  */
 protected function initializeAction()
 {
     $this->distributionSettings = $this->configurationSource->load(FLOW_PATH_CONFIGURATION . \Neos\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS);
 }
 /**
  * {@inheritdoc}
  */
 public function postProcessFormValues(array $formValues)
 {
     $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Neos.Imagine.driver', $formValues['imagineDriver']);
     $this->configurationSource->save(FLOW_PATH_CONFIGURATION . ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $this->distributionSettings);
     $this->configurationManager->flushConfigurationCache();
 }
Exemplo n.º 8
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;
 }