Neos\Flow\Configuration\ConfigurationManager::loadConfiguration PHP Method

loadConfiguration() protected method

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.
protected loadConfiguration ( string $configurationType, array $packages ) : void
$configurationType string The kind of configuration to load - must be one of the CONFIGURATION_TYPE_* constants
$packages array An array of Package objects (indexed by package key) to consider
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['Neos.Flow'])) {
                    $flowPackage = $packages['Neos.Flow'];
                    unset($packages['Neos.Flow']);
                    $packages = array_merge(['Neos.Flow' => $flowPackage], $packages);
                    unset($flowPackage);
                }
                $settings = [];
                /** @var $package PackageInterface */
                foreach ($packages as $packageKey => $package) {
                    if (Arrays::getValueByPath($settings, $packageKey) === null) {
                        $settings = Arrays::setValueByPath($settings, $packageKey, []);
                    }
                    $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] !== []) {
                    $this->configurations[$configurationType] = Arrays::arrayMergeRecursiveOverrule($this->configurations[$configurationType], $settings);
                } else {
                    $this->configurations[$configurationType] = $settings;
                }
                $this->configurations[$configurationType]['Neos']['Flow']['core']['context'] = (string) $this->context;
                break;
            case self::CONFIGURATION_PROCESSING_TYPE_OBJECTS:
                $this->configurations[$configurationType] = [];
                /** @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->temporaryDirectoryPath . 'Policy';
                    if ($this->configurationSource->has($testingPolicyPathAndFilename)) {
                        $this->configurations[$configurationType] = $this->configurationSource->load($testingPolicyPathAndFilename);
                        break;
                    }
                }
                $this->configurations[$configurationType] = [];
                /** @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] = [];
                /** @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] = [];
                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));
                // load subroutes from Routes.yaml and Settings.yaml and merge them with main routes recursively
                $this->includeSubRoutesFromSettings($this->configurations[$configurationType]);
                $this->mergeRoutesWithSubRoutes($this->configurations[$configurationType]);
                break;
            case self::CONFIGURATION_PROCESSING_TYPE_APPEND:
                $this->configurations[$configurationType] = [];
                /** @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]);
    }