/** * @param array $chainConfiguration * @return ComponentChain * @throws Exception */ public function create(array $chainConfiguration) { if (empty($chainConfiguration)) { return null; } $arraySorter = new PositionalArraySorter($chainConfiguration); $sortedChainConfiguration = $arraySorter->toArray(); $chainComponents = []; foreach ($sortedChainConfiguration as $componentName => $configuration) { $componentOptions = isset($configuration['componentOptions']) ? $configuration['componentOptions'] : []; if (isset($configuration['chain'])) { $component = $this->create($configuration['chain']); } else { if (!isset($configuration['component'])) { throw new Exception(sprintf('Component chain could not be created because no component class name is configured for component "%s"', $componentName), 1401718283); } $component = $this->objectManager->get($configuration['component'], $componentOptions); if (!$component instanceof ComponentInterface) { throw new Exception(sprintf('Component chain could not be created because the class "%s" does not implement the ComponentInterface, in component "%s" does not implement', $configuration['component'], $componentName), 1401718283); } } $chainComponents[] = $component; } return new ComponentChain(['components' => $chainComponents]); }
/** * Sort the TypoScript objects inside $this->properties depending on: * - numerical ordering * - position meta-property * * This will ignore all properties defined in "@ignoreProperties" in TypoScript * * @see PositionalArraySorter * * @return array an ordered list of keys * @throws Fusion\Exception if the positional string has an unsupported format */ protected function sortNestedTypoScriptKeys() { $arraySorter = new PositionalArraySorter($this->properties, '__meta.position'); try { $sortedTypoScriptKeys = $arraySorter->getSortedKeys(); } catch (InvalidPositionException $exception) { throw new Fusion\Exception('Invalid position string', 1345126502, $exception); } foreach ($this->ignoreProperties as $ignoredPropertyName) { $key = array_search($ignoredPropertyName, $sortedTypoScriptKeys); if ($key !== false) { unset($sortedTypoScriptKeys[$key]); } } return $sortedTypoScriptKeys; }
/** * Returns a list of presets of the specified dimension which are allowed in combination with the given presets * of other dimensions. * * @param string $dimensionName Name of the dimension to return presets for * @param array $preselectedDimensionPresets An array of dimension name and preset identifier specifying the presets which are already selected * @return array An array of presets only for the dimension specified in $dimensionName. Structure is: array($dimensionName => array('presets' => array(...)) */ public function getAllowedDimensionPresetsAccordingToPreselection($dimensionName, array $preselectedDimensionPresets) { if (!isset($this->configuration[$dimensionName])) { return null; } $dimensionConfiguration = [$dimensionName => $this->configuration[$dimensionName]]; $sorter = new PositionalArraySorter($dimensionConfiguration[$dimensionName]['presets']); $dimensionConfiguration[$dimensionName]['presets'] = $sorter->toArray(); foreach (array_keys($dimensionConfiguration[$dimensionName]['presets']) as $presetIdentifier) { $currentPresetCombination = $preselectedDimensionPresets; $currentPresetCombination[$dimensionName] = $presetIdentifier; if (!$this->isPresetCombinationAllowedByConstraints($currentPresetCombination)) { unset($dimensionConfiguration[$dimensionName]['presets'][$presetIdentifier]); } } return $dimensionConfiguration; }
/** * Returns all class names implementing the ThumbnailGeneratorInterface. * * @Flow\CompileStatic * @param ObjectManagerInterface $objectManager * @return ThumbnailGeneratorInterface[] */ public static function getThumbnailGeneratorClassNames($objectManager) { /** @var ReflectionService $reflectionService */ $reflectionService = $objectManager->get(ReflectionService::class); $generatorClassNames = $reflectionService->getAllImplementationClassNamesForInterface(ThumbnailGeneratorInterface::class); $configurationManager = $objectManager->get(ConfigurationManager::class); $generatorOptions = $configurationManager->getConfiguration('Settings', 'Neos.Media.thumbnailGenerators'); $generators = array(); foreach ($generatorClassNames as $generatorClassName) { if (isset($generatorOptions[$generatorClassName]['disable']) && $generatorOptions[$generatorClassName]['disable'] === true) { continue; } if (isset($generatorOptions[$generatorClassName]['priority'])) { $priority = $generatorOptions[$generatorClassName]['priority']; } else { $priority = $generatorClassName::getPriority(); } $generators[] = array('priority' => (int) $priority, 'className' => $generatorClassName); } $sorter = new PositionalArraySorter($generators, 'priority'); return array_reverse($sorter->toArray()); }
/** * */ public function initializeObject() { $strategyConfigurationSorter = new PositionalArraySorter($this->settings['patterns']); $this->settings['patterns'] = $strategyConfigurationSorter->toArray(); }
/** * @return string */ public function editPreviewAction() { $this->response->setHeader('Content-Type', 'application/json'); $configuration = new PositionalArraySorter(Arrays::getValueByPath($this->settings, 'userInterface.editPreviewModes')); return json_encode($configuration->toArray()); }
/** * Builds the full configuration by merging configuration from the supertypes into the local configuration. * * @return void */ protected function buildFullConfiguration() { $mergedConfiguration = array(); $applicableSuperTypes = $this->buildInheritanceChain(); foreach ($applicableSuperTypes as $key => $superType) { $mergedConfiguration = Arrays::arrayMergeRecursiveOverrule($mergedConfiguration, $superType->getLocalConfiguration()); } $this->fullConfiguration = Arrays::arrayMergeRecursiveOverrule($mergedConfiguration, $this->localConfiguration); if (isset($this->fullConfiguration['childNodes']) && is_array($this->fullConfiguration['childNodes']) && $this->fullConfiguration['childNodes'] !== array()) { $sorter = new PositionalArraySorter($this->fullConfiguration['childNodes']); $this->fullConfiguration['childNodes'] = $sorter->toArray(); } }
/** * @test * @dataProvider sampleArrays * * @param string $message * @param array $subject * @param string $positionPropertyPath * @param array $expectedKeyOrder */ public function getSortedKeysTests($message, array $subject, $positionPropertyPath, array $expectedKeyOrder) { $positionalArraySorter = new PositionalArraySorter($subject, $positionPropertyPath); $result = $positionalArraySorter->getSortedKeys(); $this->assertSame($expectedKeyOrder, $result, $message); }
/** * @return array */ protected function getNodeTypeGroupsSettings() { $settings = array(); $nodeTypeGroupsSettings = new PositionalArraySorter($this->settings['nodeTypes']['groups']); foreach ($nodeTypeGroupsSettings->toArray() as $nodeTypeGroupName => $nodeTypeGroupSettings) { if (!isset($nodeTypeGroupSettings['label'])) { continue; } $settings[] = array('name' => $nodeTypeGroupName, 'label' => $nodeTypeGroupSettings['label'], 'collapsed' => isset($nodeTypeGroupSettings['collapsed']) ? $nodeTypeGroupSettings['collapsed'] : true); } return $settings; }
/** * Evaluate processors on given value. * * @param mixed $valueToProcess * @param array $configurationWithEventualProcessors * @param string $typoScriptPath * @param AbstractTypoScriptObject $contextObject * @return mixed */ protected function evaluateProcessors($valueToProcess, $configurationWithEventualProcessors, $typoScriptPath, AbstractTypoScriptObject $contextObject = null) { if (isset($configurationWithEventualProcessors['__meta']['process'])) { $processorConfiguration = $configurationWithEventualProcessors['__meta']['process']; $positionalArraySorter = new PositionalArraySorter($processorConfiguration, '__meta.position'); foreach ($positionalArraySorter->getSortedKeys() as $key) { $processorPath = $typoScriptPath . '/__meta/process/' . $key; if ($this->evaluateIfCondition($processorConfiguration[$key], $processorPath, $contextObject) === false) { continue; } if (isset($processorConfiguration[$key]['expression'])) { $processorPath .= '/expression'; } $this->pushContext('value', $valueToProcess); $result = $this->evaluateInternal($processorPath, self::BEHAVIOR_EXCEPTION, $contextObject); if ($this->getLastEvaluationStatus() !== static::EVALUATION_SKIPPED) { $valueToProcess = $result; } $this->popContext(); } } return $valueToProcess; }