isLoaded() 공개 메소드

Returns whether the mapping is loaded.
public isLoaded ( ) : boolean
리턴 boolean Returns `true` if {@link load()} was called.
예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function rollback()
 {
     if (!$this->mapping->isLoaded()) {
         return;
     }
     $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();
 }
예제 #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
 /**
  * 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);
         }
     }
 }
예제 #4
0
 public function testUnload()
 {
     $mapping = new PathMapping('/path', 'resources');
     $mapping->load($this->package1, $this->packages);
     $mapping->unload();
     $this->assertSame(array('resources'), $mapping->getPathReferences());
     $this->assertFalse($mapping->isLoaded());
 }
 public function testClearRootPathMappings()
 {
     $this->initDefaultManager();
     $this->repo->expects($this->at(0))->method('remove')->with('/app1');
     $this->repo->expects($this->at(1))->method('remove')->with('/app2');
     $this->packageFileStorage->expects($this->once())->method('saveRootPackageFile')->with($this->rootPackageFile)->will($this->returnCallback(function (RootPackageFile $rootPackageFile) {
         PHPUnit_Framework_Assert::assertFalse($rootPackageFile->hasPathMappings());
     }));
     $this->rootPackageFile->addPathMapping($mapping1 = new PathMapping('/app1', 'resources'));
     $this->rootPackageFile->addPathMapping($mapping2 = new PathMapping('/app2', 'resources'));
     $this->manager->clearRootPathMappings();
     $this->assertFalse($mapping1->isLoaded());
     $this->assertFalse($mapping2->isLoaded());
 }