/** * Process modules after initial loading. * * @param DependencyInjectionContainer $dic * @param array $modules * @param array $config */ private function processModules(DependencyInjectionContainer $dic, array $modules, array &$config) { /** @noinspection PhpInternalEntityUsedInspection */ $dependencyGraph = new ModuleDependencyGraph(); $dependencyGraph->addModules($modules); $modules = $dependencyGraph->getSortedModuleList(); foreach ($modules as $module) { $this->loadModuleConfiguration($module, $config); } foreach ($modules as $module) { $module->configureDependencyInjection($dic, $config[$module->getModuleKey()], $config); } }
public function testCycleDetection() { //setup /** @noinspection PhpInternalEntityUsedInspection */ $graph = new ModuleDependencyGraph(); $module1 = new CyclicDependingModule1Mock(); $module2 = new CyclicDependingModule2Mock(); $module3 = new CyclicDependingModule3Mock(); $graph->addModule($module3); $graph->addModule($module2); $graph->addModule($module1); //act try { $graph->getSortedModuleList(); $this->fail(); } catch (CircularModuleLoadOrderDetectedException $e) { //pass } }