/** * {@inheritdoc} */ public function execute() { if (!$this->mapping->isLoaded()) { return; } $this->containingPackage = $this->mapping->getContainingPackage(); // Remember the conflicts that will be adjusted during unload() foreach ($this->mapping->getConflicts() as $conflict) { $this->conflicts[$conflict->getRepositoryPath()] = $conflict; $this->conflictingMappings[$conflict->getRepositoryPath()] = $conflict->getMappings(); } $packageName = $this->containingPackage->getName(); $this->mappings->remove($this->mapping->getRepositoryPath(), $packageName); foreach ($this->mapping->listRepositoryPaths() as $repositoryPath) { $this->mappingsByResource->remove($repositoryPath, $packageName); $this->conflictDetector->release($repositoryPath, $packageName); } // Unload after iterating, otherwise the paths are gone $this->mapping->unload(); }
/** * Removes a path mapping from the conflict. * * If only one path mapping is left after removing this mapping, that * mapping is removed as well. The conflict is then resolved. * * @param PathMapping $mapping The path mapping to remove. * * @throws NotLoadedException If the passed mapping is not loaded. */ public function removeMapping(PathMapping $mapping) { if (!$mapping->isLoaded()) { throw new NotLoadedException('The passed mapping must be loaded.'); } $packageName = $mapping->getContainingPackage()->getName(); if (!isset($this->mappings[$packageName]) || $mapping !== $this->mappings[$packageName]) { return; } unset($this->mappings[$packageName]); $mapping->removeConflict($this); // Conflict was resolved if (count($this->mappings) < 2) { $resolvedMappings = $this->mappings; $this->mappings = array(); foreach ($resolvedMappings as $resolvedMapping) { $resolvedMapping->removeConflict($this); } } }
public function testLoadReferencesToOtherPackage() { $mapping = new PathMapping('/path', '@vendor/package2:resources'); $this->assertSame(array('@vendor/package2:resources'), $mapping->getPathReferences()); $this->assertFalse($mapping->isLoaded()); $mapping->load($this->package1, $this->packages); $this->assertSame(array('@vendor/package2:resources'), $mapping->getPathReferences()); $this->assertSame(array($this->packageDir2 . '/resources'), $mapping->getFilesystemPaths()); $this->assertSame(array($this->packageDir2 . '/resources' => '/path', $this->packageDir2 . '/resources/config' => '/path/config', $this->packageDir2 . '/resources/config/config.yml' => '/path/config/config.yml', $this->packageDir2 . '/resources/css' => '/path/css', $this->packageDir2 . '/resources/css/style.css' => '/path/css/style.css'), $mapping->listPathMappings()); $this->assertSame(array('/path', '/path/config', '/path/config/config.yml', '/path/css', '/path/css/style.css'), $mapping->listRepositoryPaths()); $this->assertSame(array(), $mapping->getLoadErrors()); $this->assertSame($this->package1, $mapping->getContainingPackage()); $this->assertTrue($mapping->isLoaded()); }