Esempio n. 1
0
 /**
  * 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);
 }
Esempio n. 2
0
 /**
  * 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');
 }
Esempio n. 3
0
 /**
  * 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);
 }
 /**
  * @test
  */
 public function saveDoesNotOverwriteExistingHeaderCommentsIfFileExists()
 {
     $pathAndFilename = vfsStream::url('testDirectory') . '/YAMLConfiguration';
     $comment = '# This comment should stay' . chr(10) . 'Test: foo' . chr(10);
     file_put_contents($pathAndFilename . '.yaml', $comment);
     $configurationSource = new YamlSource();
     $configurationSource->save($pathAndFilename, array('configurationFileHasBeenLoaded' => true));
     $yaml = file_get_contents($pathAndFilename . '.yaml');
     $this->assertContains('# This comment should stay' . chr(10) . chr(10), $yaml, 'Header comment was removed from file.');
     $this->assertNotContains('Test: foo', $yaml);
 }
Esempio n. 5
0
 /**
  * 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);
 }
Esempio n. 6
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, '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);
         }
     }
 }
 /**
  * {@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();
 }
 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);
 }