Sets the active packages to load the configuration for
public setPackages ( array $packages ) : void | ||
$packages | array | |
return | void |
/** * @return void */ public function setUp() { parent::setUp(); // // create a mock packageManager that only returns the the packages that contain schema files // $schemaPackages = []; $configurationPackages = []; // get all packages and select the ones we want to test $temporaryPackageManager = $this->objectManager->get(PackageManagerInterface::class); foreach ($temporaryPackageManager->getActivePackages() as $package) { if (in_array($package->getPackageKey(), $this->getSchemaPackageKeys())) { $schemaPackages[$package->getPackageKey()] = $package; } if (in_array($package->getPackageKey(), $this->getConfigurationPackageKeys())) { $configurationPackages[$package->getPackageKey()] = $package; } } $this->mockPackageManager = $this->createMock(PackageManager::class); $this->mockPackageManager->expects($this->any())->method('getActivePackages')->will($this->returnValue($schemaPackages)); // // create mock configurationManager and store the original one // $this->originalConfigurationManager = $this->objectManager->get(ConfigurationManager::class); $yamlConfigurationSource = $this->objectManager->get(\Neos\Flow\Tests\Functional\Configuration\Fixtures\RootDirectoryIgnoringYamlSource::class); $this->mockConfigurationManager = clone $this->originalConfigurationManager; $this->mockConfigurationManager->setPackages($configurationPackages); $this->inject($this->mockConfigurationManager, 'configurationSource', $yamlConfigurationSource); $this->objectManager->setInstance(ConfigurationManager::class, $this->mockConfigurationManager); // // create the configurationSchemaValidator // $this->configurationSchemaValidator = $this->objectManager->get(ConfigurationSchemaValidator::class); $this->inject($this->configurationSchemaValidator, 'configurationManager', $this->mockConfigurationManager); }
/** * Initializes the Configuration Manager, the Flow settings and the Environment service * * @param Bootstrap $bootstrap * @return void * @throws FlowException */ public static function initializeConfiguration(Bootstrap $bootstrap) { $context = $bootstrap->getContext(); $environment = new Environment($context); $environment->setTemporaryDirectoryBase(FLOW_PATH_TEMPORARY_BASE); $bootstrap->setEarlyInstance(Environment::class, $environment); $packageManager = $bootstrap->getEarlyInstance(PackageManagerInterface::class); $configurationManager = new ConfigurationManager($context); $configurationManager->setTemporaryDirectoryPath($environment->getPathToTemporaryDirectory()); $configurationManager->injectConfigurationSource(new YamlSource()); $configurationManager->setPackages($packageManager->getActivePackages()); $configurationManager->loadConfigurationCache(); $settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow'); $lockManager = new LockManager($settings['utility']['lockStrategyClassName'], ['lockDirectory' => Files::concatenatePaths([$environment->getPathToTemporaryDirectory(), 'Lock'])]); Lock::setLockManager($lockManager); $packageManager->injectSettings($settings); $bootstrap->getSignalSlotDispatcher()->dispatch(ConfigurationManager::class, 'configurationManagerReady', [$configurationManager]); $bootstrap->setEarlyInstance(ConfigurationManager::class, $configurationManager); }
/** * Initializes the Configuration Manager, the Flow settings and the Environment service * * @param Bootstrap $bootstrap * @return void * @throws FlowException */ public static function initializeConfiguration(Bootstrap $bootstrap) { $context = $bootstrap->getContext(); $packageManager = $bootstrap->getEarlyInstance(PackageManagerInterface::class); $configurationManager = new ConfigurationManager($context); $configurationManager->injectConfigurationSource(new YamlSource()); $configurationManager->loadConfigurationCache(); $configurationManager->setPackages($packageManager->getActivePackages()); $settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow'); $environment = new Environment($context); if (isset($settings['utility']['environment']['temporaryDirectoryBase'])) { $defaultTemporaryDirectoryBase = FLOW_PATH_DATA . '/Temporary'; if (FLOW_PATH_TEMPORARY_BASE !== $defaultTemporaryDirectoryBase) { throw new FlowException(sprintf('It seems like the PHP default temporary base path has been changed from "%s" to "%s" via the FLOW_PATH_TEMPORARY_BASE environment variable. If that variable is present, the Neos.Flow.utility.environment.temporaryDirectoryBase setting must not be specified!', $defaultTemporaryDirectoryBase, FLOW_PATH_TEMPORARY_BASE), 1447707261); } $environment->setTemporaryDirectoryBase($settings['utility']['environment']['temporaryDirectoryBase']); } else { $environment->setTemporaryDirectoryBase(FLOW_PATH_TEMPORARY_BASE); } $configurationManager->setTemporaryDirectoryPath($environment->getPathToTemporaryDirectory()); $lockManager = new LockManager($settings['utility']['lockStrategyClassName'], ['lockDirectory' => Files::concatenatePaths([$environment->getPathToTemporaryDirectory(), 'Lock'])]); Lock::setLockManager($lockManager); $packageManager->injectSettings($settings); $bootstrap->getSignalSlotDispatcher()->dispatch(ConfigurationManager::class, 'configurationManagerReady', [$configurationManager]); $bootstrap->setEarlyInstance(ConfigurationManager::class, $configurationManager); $bootstrap->setEarlyInstance(Environment::class, $environment); }