Creates an override graph for the given modules.
public static forModules ( |
||
$modules | The modules to load. | |
return | static | The created override graph. |
/** * Adds the getModuleOrder() method. * * @param Clazz $class The factory class model. */ public function addGetModuleOrderMethod(Clazz $class) { $class->addImport(new Import('Puli\\Discovery\\Api\\Discovery')); $class->addImport(new Import('Puli\\Manager\\Api\\Server\\ServerCollection')); $class->addImport(new Import('Puli\\UrlGenerator\\Api\\UrlGenerator')); $class->addImport(new Import('Puli\\UrlGenerator\\DiscoveryUrlGenerator')); $class->addImport(new Import('RuntimeException')); $method = new Method('getModuleOrder'); $method->setDescription("Returns the order in which the installed modules should be loaded\naccording to the override statements."); $method->setReturnValue(new ReturnValue('$order', 'string[]', 'The sorted module names.')); $moduleOrderString = ''; if (count($this->modules) > 0) { $overrideGraph = DependencyGraph::forModules($this->modules); foreach ($overrideGraph->getSortedModuleNames() as $moduleName) { $moduleOrderString .= sprintf("\n %s,", var_export($moduleName, true)); } $moduleOrderString .= "\n"; } $method->addBody("\$order = array({$moduleOrderString});"); $class->addMethod($method); }
private function loadPathMappings() { $this->overrideGraph = DependencyGraph::forModules($this->modules); $this->conflictDetector = new ModuleConflictDetector($this->overrideGraph); $this->mappings = new PathMappingCollection(); $this->mappingsByResource = new PathMappingCollection(); $this->conflicts = new ConflictCollection(); // Load mappings foreach ($this->modules as $module) { if (null === $module->getModuleFile()) { continue; } foreach ($module->getModuleFile()->getPathMappings() as $mapping) { $this->loadPathMapping($mapping, $module)->execute(); } } // Scan all paths for conflicts $this->updateConflicts($this->mappingsByResource->getRepositoryPaths())->execute(); }