Example #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);
 }
 /**
  * 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');
 }
Example #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)
 {
     $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 special configuration defined in the specified packages and merges them with
  * those potentially existing in the global configuration folders. The result is stored
  * in the configuration manager's configuration registry and can be retrieved with the
  * getConfiguration() method.
  *
  * @param string $configurationType The kind of configuration to load - must be one of the CONFIGURATION_TYPE_* constants
  * @param array $packages An array of Package objects (indexed by package key) to consider
  * @throws Exception\InvalidConfigurationTypeException
  * @throws Exception\InvalidConfigurationException
  * @return void
  */
 protected function loadConfiguration($configurationType, array $packages)
 {
     $this->cacheNeedsUpdate = true;
     $configurationProcessingType = $this->resolveConfigurationProcessingType($configurationType);
     $allowSplitSource = $this->isSplitSourceAllowedForConfigurationType($configurationType);
     switch ($configurationProcessingType) {
         case self::CONFIGURATION_PROCESSING_TYPE_SETTINGS:
             // Make sure that the Flow package is the first item of the packages array:
             if (isset($packages['TYPO3.Flow'])) {
                 $flowPackage = $packages['TYPO3.Flow'];
                 unset($packages['TYPO3.Flow']);
                 $packages = array_merge(array('TYPO3.Flow' => $flowPackage), $packages);
                 unset($flowPackage);
             }
             $settings = array();
             /** @var $package PackageInterface */
             foreach ($packages as $packageKey => $package) {
                 if (Arrays::getValueByPath($settings, $packageKey) === null) {
                     $settings = Arrays::setValueByPath($settings, $packageKey, array());
                 }
                 $settings = Arrays::arrayMergeRecursiveOverrule($settings, $this->configurationSource->load($package->getConfigurationPath() . $configurationType, $allowSplitSource));
             }
             $settings = Arrays::arrayMergeRecursiveOverrule($settings, $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $configurationType, $allowSplitSource));
             foreach ($this->orderedListOfContextNames as $contextName) {
                 /** @var $package PackageInterface */
                 foreach ($packages as $package) {
                     $settings = Arrays::arrayMergeRecursiveOverrule($settings, $this->configurationSource->load($package->getConfigurationPath() . $contextName . '/' . $configurationType, $allowSplitSource));
                 }
                 $settings = Arrays::arrayMergeRecursiveOverrule($settings, $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $contextName . '/' . $configurationType, $allowSplitSource));
             }
             if ($this->configurations[$configurationType] !== array()) {
                 $this->configurations[$configurationType] = Arrays::arrayMergeRecursiveOverrule($this->configurations[$configurationType], $settings);
             } else {
                 $this->configurations[$configurationType] = $settings;
             }
             $this->configurations[$configurationType]['TYPO3']['Flow']['core']['context'] = (string) $this->context;
             break;
         case self::CONFIGURATION_PROCESSING_TYPE_OBJECTS:
             $this->configurations[$configurationType] = array();
             /** @var $package PackageInterface */
             foreach ($packages as $packageKey => $package) {
                 $configuration = $this->configurationSource->load($package->getConfigurationPath() . $configurationType);
                 $configuration = Arrays::arrayMergeRecursiveOverrule($configuration, $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $configurationType));
                 foreach ($this->orderedListOfContextNames as $contextName) {
                     $configuration = Arrays::arrayMergeRecursiveOverrule($configuration, $this->configurationSource->load($package->getConfigurationPath() . $contextName . '/' . $configurationType));
                     $configuration = Arrays::arrayMergeRecursiveOverrule($configuration, $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $contextName . '/' . $configurationType));
                 }
                 $this->configurations[$configurationType][$packageKey] = $configuration;
             }
             break;
         case self::CONFIGURATION_PROCESSING_TYPE_POLICY:
             if ($this->context->isTesting()) {
                 $testingPolicyPathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'Policy';
                 if ($this->configurationSource->has($testingPolicyPathAndFilename)) {
                     $this->configurations[$configurationType] = $this->configurationSource->load($testingPolicyPathAndFilename);
                     break;
                 }
             }
             $this->configurations[$configurationType] = array();
             /** @var $package PackageInterface */
             foreach ($packages as $package) {
                 $packagePolicyConfiguration = $this->configurationSource->load($package->getConfigurationPath() . $configurationType, $allowSplitSource);
                 $this->validatePolicyConfiguration($packagePolicyConfiguration, $package);
                 $this->configurations[$configurationType] = $this->mergePolicyConfiguration($this->configurations[$configurationType], $packagePolicyConfiguration);
             }
             $this->configurations[$configurationType] = $this->mergePolicyConfiguration($this->configurations[$configurationType], $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $configurationType, $allowSplitSource));
             foreach ($this->orderedListOfContextNames as $contextName) {
                 /** @var $package PackageInterface */
                 foreach ($packages as $package) {
                     $packagePolicyConfiguration = $this->configurationSource->load($package->getConfigurationPath() . $contextName . '/' . $configurationType, $allowSplitSource);
                     $this->validatePolicyConfiguration($packagePolicyConfiguration, $package);
                     $this->configurations[$configurationType] = $this->mergePolicyConfiguration($this->configurations[$configurationType], $packagePolicyConfiguration);
                 }
                 $this->configurations[$configurationType] = $this->mergePolicyConfiguration($this->configurations[$configurationType], $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $contextName . '/' . $configurationType, $allowSplitSource));
             }
             break;
         case self::CONFIGURATION_PROCESSING_TYPE_DEFAULT:
             $this->configurations[$configurationType] = array();
             /** @var $package PackageInterface */
             foreach ($packages as $package) {
                 $this->configurations[$configurationType] = Arrays::arrayMergeRecursiveOverrule($this->configurations[$configurationType], $this->configurationSource->load($package->getConfigurationPath() . $configurationType, $allowSplitSource));
             }
             $this->configurations[$configurationType] = Arrays::arrayMergeRecursiveOverrule($this->configurations[$configurationType], $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $configurationType, $allowSplitSource));
             foreach ($this->orderedListOfContextNames as $contextName) {
                 /** @var $package PackageInterface */
                 foreach ($packages as $package) {
                     $this->configurations[$configurationType] = Arrays::arrayMergeRecursiveOverrule($this->configurations[$configurationType], $this->configurationSource->load($package->getConfigurationPath() . $contextName . '/' . $configurationType, $allowSplitSource));
                 }
                 $this->configurations[$configurationType] = Arrays::arrayMergeRecursiveOverrule($this->configurations[$configurationType], $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $contextName . '/' . $configurationType, $allowSplitSource));
             }
             break;
         case self::CONFIGURATION_PROCESSING_TYPE_ROUTES:
             // load main routes
             $this->configurations[$configurationType] = array();
             foreach (array_reverse($this->orderedListOfContextNames) as $contextName) {
                 $this->configurations[$configurationType] = array_merge($this->configurations[$configurationType], $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $contextName . '/' . $configurationType));
             }
             $this->configurations[$configurationType] = array_merge($this->configurations[$configurationType], $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $configurationType));
             // Merge routes with SubRoutes recursively
             $this->mergeRoutesWithSubRoutes($this->configurations[$configurationType]);
             break;
         case self::CONFIGURATION_PROCESSING_TYPE_APPEND:
             $this->configurations[$configurationType] = array();
             /** @var $package PackageInterface */
             foreach ($packages as $package) {
                 $this->configurations[$configurationType] = array_merge($this->configurations[$configurationType], $this->configurationSource->load($package->getConfigurationPath() . $configurationType, $allowSplitSource));
             }
             $this->configurations[$configurationType] = array_merge($this->configurations[$configurationType], $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $configurationType, $allowSplitSource));
             foreach ($this->orderedListOfContextNames as $contextName) {
                 foreach ($packages as $package) {
                     $this->configurations[$configurationType] = array_merge($this->configurations[$configurationType], $this->configurationSource->load($package->getConfigurationPath() . $contextName . '/' . $configurationType, $allowSplitSource));
                 }
                 $this->configurations[$configurationType] = array_merge($this->configurations[$configurationType], $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $contextName . '/' . $configurationType, $allowSplitSource));
             }
             break;
         default:
             throw new Exception\InvalidConfigurationTypeException('Configuration type "' . $configurationType . '" cannot be loaded with loadConfiguration().', 1251450613);
     }
     $this->postProcessConfiguration($this->configurations[$configurationType]);
 }
 /**
  * Transforms the convoluted _FILES superglobal into a manageable form.
  *
  * @param array $convolutedFiles The _FILES superglobal
  * @return array Untangled files
  */
 protected function untangleFilesArray(array $convolutedFiles)
 {
     $untangledFiles = array();
     $fieldPaths = array();
     foreach ($convolutedFiles as $firstLevelFieldName => $fieldInformation) {
         if (!is_array($fieldInformation['error'])) {
             $fieldPaths[] = array($firstLevelFieldName);
         } else {
             $newFieldPaths = $this->calculateFieldPaths($fieldInformation['error'], $firstLevelFieldName);
             array_walk($newFieldPaths, function (&$value) {
                 $value = explode('/', $value);
             });
             $fieldPaths = array_merge($fieldPaths, $newFieldPaths);
         }
     }
     foreach ($fieldPaths as $fieldPath) {
         if (count($fieldPath) === 1) {
             $fileInformation = $convolutedFiles[$fieldPath[0]];
         } else {
             $fileInformation = array();
             foreach ($convolutedFiles[$fieldPath[0]] as $key => $subStructure) {
                 $fileInformation[$key] = Arrays::getValueByPath($subStructure, array_slice($fieldPath, 1));
             }
         }
         if (isset($fileInformation['error']) && $fileInformation['error'] !== \UPLOAD_ERR_NO_FILE) {
             $untangledFiles = Arrays::setValueByPath($untangledFiles, $fieldPath, $fileInformation);
         }
     }
     return $untangledFiles;
 }
Example #6
0
 /**
  * Sets the default value of a form element
  *
  * @param string $elementIdentifier identifier of the form element. This supports property paths!
  * @param mixed $defaultValue
  * @return void
  * @internal
  */
 public function addElementDefaultValue($elementIdentifier, $defaultValue)
 {
     $this->elementDefaultValues = \TYPO3\Flow\Utility\Arrays::setValueByPath($this->elementDefaultValues, $elementIdentifier, $defaultValue);
 }
 /**
  * @param NodeInterface $systemNode
  * @param array $identifierValues
  * @return void
  */
 protected function cacheSystemNode(NodeInterface $systemNode, array $identifierValues)
 {
     $ancestorNodeTypeName = $systemNode->getNodeType()->getConfiguration('systemNode.ancestorToBeResolved');
     if ($ancestorNodeTypeName) {
         $systemNode = $this->fetchClosestAncestorNode($systemNode, $ancestorNodeTypeName);
     }
     if ($systemNode) {
         $this->systemNodeIdentifiers = Arrays::setValueByPath($this->systemNodeIdentifiers, $identifierValues, $systemNode->getIdentifier());
     }
 }
Example #8
0
 /**
  * @param string $propertyPath
  * @param mixed $value
  * @return void
  */
 public function setFormValue($propertyPath, $value)
 {
     $this->formValues = \TYPO3\Flow\Utility\Arrays::setValueByPath($this->formValues, $propertyPath, $value);
 }
 /**
  * {@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();
 }
 /**
  * Reconstitues related entities to an unserialized object in __wakeup.
  * Used in __wakeup methods of proxy classes.
  *
  * Note: This method adds code which ignores objects of type TYPO3\Flow\Resource\ResourcePointer in order to provide
  * backwards compatibility data generated with Flow 2.2.x which still provided that class.
  *
  * @return void
  */
 private function Flow_setRelatedEntities()
 {
     if (property_exists($this, 'Flow_Persistence_RelatedEntities') && is_array($this->Flow_Persistence_RelatedEntities)) {
         $persistenceManager = \TYPO3\Flow\Core\Bootstrap::$staticObjectManager->get('TYPO3\\Flow\\Persistence\\PersistenceManagerInterface');
         foreach ($this->Flow_Persistence_RelatedEntities as $entityInformation) {
             if ($entityInformation['entityType'] === 'TYPO3\\Flow\\Resource\\ResourcePointer') {
                 continue;
             }
             $entity = $persistenceManager->getObjectByIdentifier($entityInformation['identifier'], $entityInformation['entityType'], true);
             if (isset($entityInformation['entityPath'])) {
                 $this->{$entityInformation['propertyName']} = \TYPO3\Flow\Utility\Arrays::setValueByPath($this->{$entityInformation['propertyName']}, $entityInformation['entityPath'], $entity);
             } else {
                 $this->{$entityInformation['propertyName']} = $entity;
             }
         }
         unset($this->Flow_Persistence_RelatedEntities);
     }
 }
 /**
  * @param string $errors
  *
  * @return void
  */
 private function renderPrettyYaml($providerName)
 {
     $errors = $this->defaultMapperValidator->getValidationErrors($providerName);
     if (empty($errors)) {
         return;
     }
     $settings = [];
     $this->outputLine(PHP_EOL . 'Settings for <b>"%s"</b> are not valid!' . PHP_EOL, [$providerName]);
     /* @var $error \TYPO3\Flow\Error\Error */
     foreach ($errors as $error) {
         $parentPath = implode('.', explode('.', $error->getTitle(), -1));
         $parentNode = ArraysUtility::getValueByPath($settings, $parentPath);
         if (is_string($parentNode) && preg_match('/^<b># /', $parentNode)) {
             continue;
         }
         $settings = ArraysUtility::setValueByPath($settings, $error->getTitle(), '<b># ' . $error->getCode() . '</b>');
     }
     // fix representation of roles in yaml
     $roleErrors = ArraysUtility::getValueByPath($settings, 'TYPO3.Flow.security.authentication.providers.' . $providerName . '.providerOptions.Mapping.Roles');
     $maxNumber = max(array_keys($roleErrors));
     for ($index = 0; $index <= $maxNumber; $index++) {
         if (!empty($roleErrors[$index])) {
             continue;
         }
         $path = 'TYPO3.Flow.security.authentication.providers.' . $providerName . '.providerOptions.Mapping.Roles.' . $index;
         $realSettings = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $path);
         $settings = ArraysUtility::setValueByPath($settings, $path, $realSettings);
     }
     $roleErrors = ArraysUtility::getValueByPath($settings, 'TYPO3.Flow.security.authentication.providers.' . $providerName . '.providerOptions.Mapping.Roles');
     ksort($roleErrors);
     $settings = ArraysUtility::setValueByPath($settings, 'TYPO3.Flow.security.authentication.providers.' . $providerName . '.providerOptions.Mapping.Roles', $roleErrors);
     $this->outputLine('<b>See this on YAML:</b> errors are bold and with # marked.');
     $this->outputLine('<b>' . str_repeat('-', self::MAXIMUM_LINE_LENGTH) . '</b>');
     $yaml = \Symfony\Component\Yaml\Yaml::dump($settings, 99, 2);
     $this->output($yaml);
     $this->outputLine('<b>' . str_repeat('-', self::MAXIMUM_LINE_LENGTH) . '</b>');
 }
Example #12
0
 /**
  * @param string $path
  * @param array  $value
  * @Flow\Session(autoStart = TRUE)
  *
  * @return void
  */
 public function setMiscellaneousByPath($path, $value)
 {
     $this->miscellaneous = ArraysUtility::setValueByPath($this->miscellaneous, $path, $value);
 }
Example #13
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 setValueByLeavesInputArrayUnchanged()
 {
     $subject = $subjectBackup = array('foo' => 'bar');
     \TYPO3\Flow\Utility\Arrays::setValueByPath($subject, 'foo', 'baz');
     $this->assertEquals($subject, $subjectBackup);
 }
 /**
  * @param NodeInterface $rootNode
  * @param array<\TYPO3\TYPO3CR\Domain\Model\NodeData> $nodes
  * @return array
  */
 public function collectParentNodeData(NodeInterface $rootNode, array $nodes)
 {
     $nodeCollection = array();
     $addNode = function ($node, $matched) use($rootNode, &$nodeCollection) {
         /** @var NodeInterface $node */
         $path = str_replace('/', '.children.', substr($node->getPath(), strlen($rootNode->getPath()) + 1));
         if ($path !== '') {
             $nodeCollection = Arrays::setValueByPath($nodeCollection, $path . '.node', $node);
             if ($matched === TRUE) {
                 $nodeCollection = Arrays::setValueByPath($nodeCollection, $path . '.matched', TRUE);
             }
         }
     };
     $findParent = function ($node) use(&$findParent, &$addNode) {
         /** @var NodeInterface $node */
         $parent = $node->getParent();
         if ($parent !== NULL) {
             $addNode($parent, FALSE);
             $findParent($parent);
         }
     };
     foreach ($nodes as $node) {
         $addNode($node, TRUE);
         $findParent($node);
     }
     $treeNodes = array();
     $self = $this;
     $collectTreeNodeData = function (&$treeNodes, $node) use(&$collectTreeNodeData, $self) {
         $children = array();
         if (isset($node['children'])) {
             foreach ($node['children'] as $childNode) {
                 $collectTreeNodeData($children, $childNode);
             }
         }
         $treeNodes[] = $self->collectTreeNodeData($node['node'], TRUE, $children, $children !== array(), isset($node['matched']));
     };
     foreach ($nodeCollection as $firstLevelNode) {
         $collectTreeNodeData($treeNodes, $firstLevelNode);
     }
     return $treeNodes;
 }
 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);
 }
 /**
  * @return void
  */
 public function updateSettings()
 {
     $settings = $this->getSettings();
     $updatableSettings = array();
     foreach ($this->updatableSettings as $settingPath) {
         $setting = Arrays::getValueByPath($settings, $settingPath);
         if ($setting !== null) {
             $updatableSettings = Arrays::setValueByPath($updatableSettings, $settingPath, $setting);
         }
     }
     $this->request('PUT', '/_settings', array(), json_encode($updatableSettings));
 }
 /**
  * Gets a property setting by its path
  *
  * @param array|string $path
  * @param string $value
  * @return void
  */
 public function setPropertyByPath($path, $value)
 {
     $this->properties = \TYPO3\Flow\Utility\Arrays::setValueByPath($this->properties, $path, $value);
 }
 /**
  * Checks whether $routePath corresponds to this Route.
  * If all Route Parts match successfully TRUE is returned and
  * $this->matchResults contains an array combining Route default values and
  * calculated matchResults from the individual Route Parts.
  *
  * @param \TYPO3\Flow\Http\Request $httpRequest the HTTP request to match
  * @return boolean TRUE if this Route corresponds to the given $routePath, otherwise FALSE
  * @throws InvalidRoutePartValueException
  * @see getMatchResults()
  */
 public function matches(Request $httpRequest)
 {
     $routePath = $httpRequest->getRelativePath();
     $this->matchResults = null;
     if ($this->uriPattern === null) {
         return false;
     }
     if (!$this->isParsed) {
         $this->parse();
     }
     if ($this->hasHttpMethodConstraints() && !in_array($httpRequest->getMethod(), $this->httpMethods)) {
         return false;
     }
     $matchResults = array();
     $routePath = trim($routePath, '/');
     $skipOptionalParts = false;
     $optionalPartCount = 0;
     /** @var $routePart RoutePartInterface */
     foreach ($this->routeParts as $routePart) {
         if ($routePart->isOptional()) {
             $optionalPartCount++;
             if ($skipOptionalParts) {
                 if ($routePart->getDefaultValue() === null) {
                     return false;
                 }
                 continue;
             }
         } else {
             $optionalPartCount = 0;
             $skipOptionalParts = false;
         }
         if ($routePart->match($routePath) !== true) {
             if ($routePart->isOptional() && $optionalPartCount === 1) {
                 if ($routePart->getDefaultValue() === null) {
                     return false;
                 }
                 $skipOptionalParts = true;
             } else {
                 return false;
             }
         }
         $routePartValue = $routePart->getValue();
         if ($routePartValue !== null) {
             if ($this->containsObject($routePartValue)) {
                 throw new InvalidRoutePartValueException('RoutePart::getValue() must only return simple types after calling RoutePart::match(). RoutePart "' . get_class($routePart) . '" returned one or more objects in Route "' . $this->getName() . '".');
             }
             $matchResults = Arrays::setValueByPath($matchResults, $routePart->getName(), $routePartValue);
         }
     }
     if (strlen($routePath) > 0) {
         return false;
     }
     $this->matchResults = Arrays::arrayMergeRecursiveOverrule($this->defaults, $matchResults);
     return true;
 }
Example #20
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();
 }
Example #21
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 \TYPO3\Flow\Configuration\Source\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 = \TYPO3\Flow\Utility\Arrays::setValueByPath($distributionSettings, 'TYPO3.Flow.core.phpBinaryPathAndFilename', $phpBinaryPathAndFilename);
             $configurationSource->save(FLOW_PATH_CONFIGURATION . ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $distributionSettings);
         }
     }
     return $message;
 }
 /**
  * Autogenerated Proxy Method
  */
 private function searchForEntitiesAndStoreIdentifierArray($path, $propertyValue, $originalPropertyName)
 {
     if (is_array($propertyValue) || is_object($propertyValue) && ($propertyValue instanceof \ArrayObject || $propertyValue instanceof \SplObjectStorage)) {
         foreach ($propertyValue as $key => $value) {
             $this->searchForEntitiesAndStoreIdentifierArray($path . '.' . $key, $value, $originalPropertyName);
         }
     } elseif ($propertyValue instanceof \TYPO3\Flow\Persistence\Aspect\PersistenceMagicInterface && !\TYPO3\Flow\Core\Bootstrap::$staticObjectManager->get('TYPO3\\Flow\\Persistence\\PersistenceManagerInterface')->isNewObject($propertyValue) || $propertyValue instanceof \Doctrine\ORM\Proxy\Proxy) {
         if (!property_exists($this, 'Flow_Persistence_RelatedEntities') || !is_array($this->Flow_Persistence_RelatedEntities)) {
             $this->Flow_Persistence_RelatedEntities = array();
             $this->Flow_Object_PropertiesToSerialize[] = 'Flow_Persistence_RelatedEntities';
         }
         if ($propertyValue instanceof \Doctrine\ORM\Proxy\Proxy) {
             $className = get_parent_class($propertyValue);
         } else {
             $className = \TYPO3\Flow\Core\Bootstrap::$staticObjectManager->getObjectNameByClassName(get_class($propertyValue));
         }
         $identifier = \TYPO3\Flow\Core\Bootstrap::$staticObjectManager->get('TYPO3\\Flow\\Persistence\\PersistenceManagerInterface')->getIdentifierByObject($propertyValue);
         if (!$identifier && $propertyValue instanceof \Doctrine\ORM\Proxy\Proxy) {
             $identifier = current(\TYPO3\Flow\Reflection\ObjectAccess::getProperty($propertyValue, '_identifier', TRUE));
         }
         $this->Flow_Persistence_RelatedEntities[$originalPropertyName . '.' . $path] = array('propertyName' => $originalPropertyName, 'entityType' => $className, 'identifier' => $identifier, 'entityPath' => $path);
         $this->{$originalPropertyName} = \TYPO3\Flow\Utility\Arrays::setValueByPath($this->{$originalPropertyName}, $path, NULL);
     }
 }
 /**
  * @param MappingAnnotation $annotation
  * @param array $propertyMapping
  * @return array
  */
 protected function processMappingAnnotation(MappingAnnotation $annotation, $propertyMapping = array())
 {
     foreach ($annotation->getPropertiesArray() as $mappingDirective => $directiveValue) {
         if ($directiveValue === NULL) {
             continue;
         }
         $propertyMapping = Arrays::setValueByPath($propertyMapping, $mappingDirective, $directiveValue);
     }
     return $propertyMapping;
 }