/** * Loads a specific version into an array. * * @param string $version * @return array * @throws \TYPO3\TYPO3CR\Migration\Exception\MigrationException */ protected function loadConfiguration($version) { if (!$this->isVersionAvailable($version)) { throw new \TYPO3\TYPO3CR\Migration\Exception\MigrationException('The requested YamlConfiguration was not available.', 1345822283); } $configuration = $this->yamlSourceImporter->load(substr($this->availableVersions[$version]['filePathAndName'], 0, -5)); return $configuration; }
/** * Update global Piwik settings * * @param array $piwik * @return void */ public function updateAction(array $piwik) { $configurationPath = $this->packageManager->getPackage('Portachtzig.Neos.Piwik')->getConfigurationPath(); $settings = $this->configurationSource->load($configurationPath . ConfigurationManager::CONFIGURATION_TYPE_SETTINGS); $piwik['host'] = preg_replace("(^https?://)", "", $piwik['host']); $settings = Arrays::setValueByPath($settings, 'Portachtzig.Neos.Piwik.host', $piwik['host']); $settings = Arrays::setValueByPath($settings, 'Portachtzig.Neos.Piwik.protocol', $piwik['protocol']); $settings = Arrays::setValueByPath($settings, 'Portachtzig.Neos.Piwik.token_auth', $piwik['token_auth']); if (array_key_exists('idSite', $piwik)) { $settings = Arrays::setValueByPath($settings, 'Portachtzig.Neos.Piwik.idSite', $piwik['idSite']); } $this->configurationSource->save($configurationPath . ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $settings); $this->configurationManager->flushConfigurationCache(); $this->redirect('index'); }
/** * 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 = array(); foreach ($routesConfiguration as $routeConfiguration) { if (!isset($routeConfiguration['subRoutes'])) { $mergedRoutesConfiguration[] = $routeConfiguration; continue; } $mergedSubRoutesConfiguration = array($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 = array(); 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_RECURSIONS) { throw new Exception\RecursionException(sprintf('Recursion level of SubRoutes exceed ' . self::MAXIMUM_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; }
/** * 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); } } }
/** * @return void */ protected function initializeAction() { $this->distributionSettings = $this->configurationSource->load(FLOW_PATH_CONFIGURATION . \TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS); }
/** * @test */ public function splitConfigurationFilesAreMergedAsExpected() { $expectedConfiguration = array('configurationFileHasBeenLoaded' => true, 'TYPO3' => array('Flow' => array('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); }
protected function saveUserSettings() { $frameworkConfiguration = $this->configurationSource->load(FLOW_PATH_CONFIGURATION . ConfigurationManager::CONFIGURATION_TYPE_SETTINGS); $frameworkConfiguration = Arrays::setValueByPath($frameworkConfiguration, 'Neos.Contribute.gitHub', $this->gitHubSettings); $this->configurationSource->save(FLOW_PATH_CONFIGURATION . ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $frameworkConfiguration); }