forModules() 공개 정적인 메소드

Creates an override graph for the given modules.
public static forModules ( ModuleList $modules ) : static
$modules Puli\Manager\Api\Module\ModuleList The modules to load.
리턴 static The created override graph.
예제 #1
0
 /**
  * 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);
 }
예제 #2
0
 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();
 }