/** * 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; }
/** * This method is called when the form of this step has been submitted * * @param array $formValues * @return void */ public function postProcessFormValues(array $formValues) { if (empty($formValues['defaultDeploymentPath']) === FALSE) { $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.frontendSettings.defaultDeploymentPath', $formValues['defaultDeploymentPath']); } if (empty($formValues['defaultUser']) === FALSE) { $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.frontendSettings.defaultUser', $formValues['defaultUser']); } $this->configurationSource->save(FLOW_PATH_CONFIGURATION . ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $this->distributionSettings); }
/** * 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'); }
/** * This method is called when the form of this step has been submitted * * @param array $formValues * @return void */ public function postProcessFormValues(array $formValues) { $settings = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Lightwerk.SurfCaptain'); $driver = $settings['sources']['default']['driver']; $repositories = Arrays::trimExplode(',', $formValues['repositories']); // reset $this->distributionSettings['Lightwerk']['SurfCaptain']['sources']['default']['repositories'] = array(); for ($i = 0; $i < count($repositories); $i++) { $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.repositories.' . $i, $repositories[$i]); } $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.privateToken', $formValues['privateToken']); switch ($driver) { case 'GitHub': $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.accountName', '*****@*****.**'); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.apiUrl', 'https://api.github.com/'); break; case 'GitLab': $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.accountName', $formValues['accountName']); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.apiUrl', $formValues['apiUrl']); break; case 'BitBucket': $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.accountName', $formValues['accountName']); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.apiUrl', 'https://api.bitbucket.org/2.0/'); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.fallbackApiUrl', 'https://api.bitbucket.org/1.0/'); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.privateSecret', $formValues['privateSecret']); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.accessToken', $formValues['accessToken']); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.accessSecret', $formValues['accessSecret']); break; default: throw new SetupException('Unknown driver ' . $driver, 1427623122); } $this->configurationSource->save(FLOW_PATH_CONFIGURATION . ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $this->distributionSettings); }
/** * This method is called when the form of this step has been submitted * * @param array $formValues * @return void */ public function postProcessFormValues(array $formValues) { $driver = $formValues['gitDriver']; $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.driver', $driver); // reset $this->distributionSettings['Lightwerk']['SurfCaptain']['sources']['default']['mapping'] = array(); switch ($driver) { case 'GitHub': $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.mapping.Repository.repositoryUrl', '{{ssh_url}}'); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.mapping.Repository.webUrl', '{{url}}'); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.mapping.Commit.id', '{{sha}}'); break; case 'GitLab': $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.mapping.Repository.repositoryUrl', '{{ssh_url_to_repo}}'); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.mapping.Commit.date', '{{committed_date}}'); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.mapping.Commit.committerName', '{{committer.name}}'); break; case 'BitBucket': $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.mapping.Repository.webUrl', '{{links.html.href}}'); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.mapping.Repository.repositoryUrl', '{{links.clone.1.href}}'); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.mapping.Branch.name', '{{branch}}'); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.mapping.Branch.commit.id', '{{raw_node}}'); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.mapping.Branch.commit.committerName', '{{author}}'); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.mapping.Branch.commit.date', '{{timestamp}}'); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.mapping.Branch.commit.message', '{{message}}'); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.mapping.Tag.name', '{{_KEY_}}'); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.mapping.Tag.commit.id', '{{raw_node}}'); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.mapping.Tag.commit.committerName', '{{author}}'); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.mapping.Tag.commit.date', '{{timestamp}}'); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.sources.default.mapping.Tag.commit.message', '{{message}}'); break; default: throw new SetupException('unknown driver ' . $driver, 1427623122); } $this->configurationSource->save(FLOW_PATH_CONFIGURATION . ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $this->distributionSettings); }
/** * 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; }
/** * 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, 'TYPO3.Flow.persistence.backendOptions.driver', $formValues['driver']); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'TYPO3.Flow.persistence.backendOptions.dbname', $formValues['dbname']); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'TYPO3.Flow.persistence.backendOptions.user', $formValues['user']); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'TYPO3.Flow.persistence.backendOptions.password', $formValues['password']); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'TYPO3.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, 'TYPO3.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('typo3.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 typo3.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); } } }
/** * @return void */ protected function initializeAction() { $this->distributionSettings = $this->configurationSource->load(FLOW_PATH_CONFIGURATION . \TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS); }
/** * {@inheritdoc} */ public function postProcessFormValues(array $formValues) { $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'TYPO3.Imagine.driver', $formValues['imagineDriver']); $this->configurationSource->save(FLOW_PATH_CONFIGURATION . ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $this->distributionSettings); $this->configurationManager->flushConfigurationCache(); }
/** * @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); }