Ejemplo n.º 1
0
 private function loadPathMappings()
 {
     $this->overrideGraph = OverrideGraph::forPackages($this->packages);
     $this->conflictDetector = new PackageConflictDetector($this->overrideGraph);
     $this->mappings = new PathMappingCollection();
     $this->mappingsByResource = new PathMappingCollection();
     $this->conflicts = new ConflictCollection();
     // Load mappings
     foreach ($this->packages as $package) {
         foreach ($package->getPackageFile()->getPathMappings() as $mapping) {
             $this->loadPathMapping($mapping, $package)->execute();
         }
     }
     // Scan all paths for conflicts
     $this->updateConflicts($this->mappingsByResource->getRepositoryPaths())->execute();
 }
Ejemplo n.º 2
0
 /**
  * Adds the getPackageOrder() method.
  *
  * @param Clazz $class The factory class model.
  */
 public function addGetPackageOrderMethod(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('getPackageOrder');
     $method->setDescription("Returns the order in which the installed packages should be loaded\naccording to the override statements.");
     $method->setReturnValue(new ReturnValue('$order', 'string[]', 'The sorted package names.'));
     $packageOrderString = '';
     if (count($this->packages) > 0) {
         $overrideGraph = OverrideGraph::forPackages($this->packages);
         foreach ($overrideGraph->getSortedPackageNames() as $packageName) {
             $packageOrderString .= sprintf("\n    %s,", var_export($packageName, true));
         }
         $packageOrderString .= "\n";
     }
     $method->addBody("\$order = array({$packageOrderString});");
     $class->addMethod($method);
 }