load() публичный Метод

Loads the mapping.
public load ( Puli\Manager\Api\Module\Module $containingModule, ModuleList $modules )
$containingModule Puli\Manager\Api\Module\Module The module that contains the mapping.
$modules Puli\Manager\Api\Module\ModuleList A list of modules that can be referenced using `@vendor/module:` prefixes in the path references.
Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     if ($this->mapping->isLoaded()) {
         return;
     }
     $this->mapping->load($this->containingPackage, $this->packages);
     $packageName = $this->containingPackage->getName();
     $this->mappings->add($this->mapping);
     foreach ($this->mapping->listRepositoryPaths() as $repositoryPath) {
         $this->mappingsByResource->set($repositoryPath, $this->mapping);
         $this->conflictDetector->claim($repositoryPath, $packageName);
     }
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function rollback()
 {
     if ($this->mapping->isLoaded() || !$this->containingModule) {
         return;
     }
     $this->mapping->load($this->containingModule, $this->modules);
     $moduleName = $this->containingModule->getName();
     foreach ($this->mapping->listRepositoryPaths() as $repositoryPath) {
         $this->mappings->add($this->mapping);
         $this->conflictDetector->claim($repositoryPath, $moduleName);
     }
     // Restore conflicts
     foreach ($this->conflicts as $repositoryPath => $conflict) {
         $conflict->addMappings($this->conflictingMappings[$repositoryPath]);
     }
 }
Пример #3
0
 private function initDefaultManager()
 {
     $conflictMappingRoot1 = new PathMapping('/conflict1', array('res', 'assets'));
     $conflictMappingPackage11 = new PathMapping('/conflict1', array('res', '@vendor/package2:res'));
     $conflictMappingPackage12 = new PathMapping('/conflict2', 'res');
     $conflictMappingPackage21 = new PathMapping('/conflict1', 'res');
     $conflictMappingPackage22 = new PathMapping('/conflict2', 'res');
     $conflictMappingRoot1->load($this->packages->getRootPackage(), $this->packages);
     $conflictMappingPackage11->load($this->packages->get('vendor/package1'), $this->packages);
     $conflictMappingPackage12->load($this->packages->get('vendor/package1'), $this->packages);
     $conflictMappingPackage21->load($this->packages->get('vendor/package2'), $this->packages);
     $conflictMappingPackage22->load($this->packages->get('vendor/package2'), $this->packages);
     $conflict1 = new PathConflict('/conflict1');
     $conflict1->addMappings(array($conflictMappingRoot1, $conflictMappingPackage11, $conflictMappingPackage21));
     $conflict2 = new PathConflict('/conflict2/sub/path');
     $conflict2->addMappings(array($conflictMappingPackage12, $conflictMappingPackage22));
     $this->repoManager->expects($this->any())->method('findPathMappings')->willReturnCallback($this->returnFromMap(array(array($this->packageAndState('vendor/root', PathMappingState::ENABLED), array(new PathMapping('/root/enabled', array('res', 'assets')))), array($this->packageAndState('vendor/package1', PathMappingState::ENABLED), array(new PathMapping('/package1/enabled', array('res', '@vendor/package2:res')))), array($this->packageAndState('vendor/package2', PathMappingState::ENABLED), array(new PathMapping('/package2/enabled', 'res'))), array($this->packageAndState('vendor/root', PathMappingState::NOT_FOUND), array(new PathMapping('/root/not-found', 'res'))), array($this->packageAndState('vendor/package1', PathMappingState::NOT_FOUND), array(new PathMapping('/package1/not-found', 'res'))), array($this->packageAndState('vendor/package2', PathMappingState::NOT_FOUND), array(new PathMapping('/package2/not-found', 'res'))), array($this->packagesAndState(array('vendor/root'), PathMappingState::CONFLICT), array($conflictMappingRoot1)), array($this->packagesAndState(array('vendor/package1'), PathMappingState::CONFLICT), array($conflictMappingPackage11, $conflictMappingPackage12)), array($this->packagesAndState(array('vendor/package2'), PathMappingState::CONFLICT), array($conflictMappingPackage21, $conflictMappingPackage22)), array($this->packagesAndState(array('vendor/root', 'vendor/package1'), PathMappingState::CONFLICT), array($conflictMappingRoot1, $conflictMappingPackage11, $conflictMappingPackage12)), array($this->packagesAndState(array('vendor/root', 'vendor/package2'), PathMappingState::CONFLICT), array($conflictMappingRoot1, $conflictMappingPackage21, $conflictMappingPackage22)), array($this->packagesAndState(array('vendor/package1', 'vendor/package2'), PathMappingState::CONFLICT), array($conflictMappingPackage11, $conflictMappingPackage12, $conflictMappingPackage21, $conflictMappingPackage22)), array($this->packagesAndState(array('vendor/root', 'vendor/package1', 'vendor/package2'), PathMappingState::CONFLICT), array($conflictMappingRoot1, $conflictMappingPackage11, $conflictMappingPackage12, $conflictMappingPackage21, $conflictMappingPackage22)))));
 }
Пример #4
0
 public function testResolveRemovesAllMappings()
 {
     $mapping1 = new PathMapping('/path', 'resources');
     $mapping1->load($this->package1, $this->packages);
     $mapping2 = new PathMapping('/path', 'resources');
     $mapping2->load($this->package2, $this->packages);
     $mapping3 = new PathMapping('/path', 'resources');
     $mapping3->load($this->package3, $this->packages);
     $conflict = new PathConflict('/path/conflict');
     $conflict->addMapping($mapping1);
     $conflict->addMapping($mapping2);
     $conflict->addMapping($mapping3);
     $conflict->resolve();
     $this->assertCount(0, $conflict->getMappings());
     $this->assertCount(0, $mapping1->getConflicts());
     $this->assertCount(0, $mapping2->getConflicts());
     $this->assertCount(0, $mapping3->getConflicts());
     $this->assertTrue($conflict->isResolved());
 }
Пример #5
0
 public function testMatch()
 {
     $mapping = new PathMapping('/path', 'resources');
     $mapping->load($this->package1, $this->packages);
     $this->assertFalse($mapping->match(Expr::same('foobar', PathMapping::CONTAINING_PACKAGE)));
     $this->assertTrue($mapping->match(Expr::same($this->package1->getName(), PathMapping::CONTAINING_PACKAGE)));
     $this->assertFalse($mapping->match(Expr::same(PathMappingState::CONFLICT, PathMapping::STATE)));
     $this->assertTrue($mapping->match(Expr::same(PathMappingState::ENABLED, PathMapping::STATE)));
     $this->assertFalse($mapping->match(Expr::startsWith('/foo', PathMapping::REPOSITORY_PATH)));
     $this->assertTrue($mapping->match(Expr::startsWith('/pa', PathMapping::REPOSITORY_PATH)));
 }