/**
  * @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 = array();
     foreach ($sortedChainConfiguration as $componentName => $configuration) {
         $componentOptions = isset($configuration['componentOptions']) ? $configuration['componentOptions'] : array();
         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(array('components' => $chainComponents));
 }
 /**
  * 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 = array($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;
 }
 /**
  * Creates a monolog instance.
  *
  * @param string $identifier An identifier for the logger
  * @param array $configuration
  * @return Logger
  */
 public function createFromConfiguation($identifier, array $configuration)
 {
     if (isset($this->loggerInstances[$identifier])) {
         return $this->loggerInstances[$identifier];
     }
     $logger = new Logger($identifier);
     $handlerSorter = new PositionalArraySorter($configuration['handler']);
     foreach ($handlerSorter->toArray() as $index => $handlerConfiguration) {
         if (is_string($handlerConfiguration)) {
             $handler = $this->getConfiguredHandler($handlerConfiguration);
         }
         if (is_array($handlerConfiguration)) {
             $handlerIdentifier = $identifier . md5(json_encode($handlerConfiguration));
             $handler = $this->instanciateHandler($handlerIdentifier, $handlerConfiguration);
         }
         if ($handler !== NULL) {
             $logger->pushHandler($handler);
         }
     }
     $this->loggerInstances[$identifier] = $logger;
     return $logger;
 }
 /**
  * Returns all class names implementing the ThumbnailGeneratorInterface.
  *
  * @param ObjectManagerInterface $objectManager
  * @return ThumbnailGeneratorInterface[]
  * @Flow\CompileStatic
  */
 protected 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', 'TYPO3.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());
 }
 /**
  * @test
  * @dataProvider sampleArrays
  *
  * @param string $message
  * @param array $subject
  * @param string $positionPropertyPath
  * @param array $expectedKeyOrder
  */
 public function toArrayTests($message, array $subject, $positionPropertyPath, array $expectedKeyOrder)
 {
     $positionalArraySorter = new PositionalArraySorter($subject, $positionPropertyPath);
     $result = $positionalArraySorter->toArray();
     $this->assertSame($expectedKeyOrder, array_keys($result), $message);
 }
 /**
  * @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());
 }
 /**
  *
  */
 public function initializeObject()
 {
     $strategyConfigurationSorter = new PositionalArraySorter($this->settings['patterns']);
     $this->settings['patterns'] = $strategyConfigurationSorter->toArray();
 }
 /**
  * @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;
 }
 /**
  * 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();
     }
 }