private function updateDuplicateMarksForTypeName($typeName) { if (!$this->typeDescriptors->contains($typeName)) { return; } $typeDescriptors = $this->typeDescriptors->listByTypeName($typeName); $duplicate = count($typeDescriptors) > 1; foreach ($typeDescriptors as $typeDescriptor) { $typeDescriptor->markDuplicate($duplicate); } }
/** * {@inheritdoc} */ public function execute() { // sanity check if ($this->bindingDescriptor->isLoaded()) { return; } $typeName = $this->bindingDescriptor->getTypeName(); $typeDescriptor = $this->typeDescriptors->contains($typeName) ? $this->typeDescriptors->getFirst($typeName) : null; $this->bindingDescriptor->load($this->containingPackage, $typeDescriptor); $uuid = $this->bindingDescriptor->getUuid(); if ($this->bindingDescriptors->contains($uuid)) { $this->previousDescriptor = $this->bindingDescriptors->get($uuid); } $this->bindingDescriptors->add($this->bindingDescriptor); }
/** * {@inheritdoc} */ public function execute() { // sanity check if ($this->typeDescriptor->isLoaded()) { return; } // never fails with the check before $this->typeDescriptor->load($this->containingPackage); $typeName = $this->typeDescriptor->getTypeName(); $packageName = $this->containingPackage->getName(); if ($this->typeDescriptors->contains($typeName, $packageName)) { // never fails with the check before $this->previousDescriptor = $this->typeDescriptors->get($typeName, $packageName); } // never fails $this->typeDescriptors->add($this->typeDescriptor); }
/** * {@inheritdoc} */ public function execute() { // sanity check if (!$this->typeDescriptor->isLoaded()) { return; } // never fails with the check before $this->containingModule = $this->typeDescriptor->getContainingModule(); $typeName = $this->typeDescriptor->getTypeName(); $moduleName = $this->containingModule->getName(); // never fails with the check before $this->typeDescriptor->unload(); if ($this->typeDescriptors->contains($typeName, $moduleName) && $this->typeDescriptor === $this->typeDescriptors->get($typeName, $moduleName)) { // never fails $this->typeDescriptors->remove($typeName, $moduleName); $this->wasRemoved = true; } }
/** * {@inheritdoc} */ public function execute() { if (!$this->snapshotTaken) { throw new LogicException('takeSnapshot() was not called'); } // Remember for rollback() $this->enabledTypeAfter = null; if ($this->typeDescriptors->contains($this->typeName)) { foreach ($this->typeDescriptors->listByTypeName($this->typeName) as $typeDescriptor) { if ($typeDescriptor->isEnabled()) { $this->enabledTypeAfter = $typeDescriptor; } } } $this->syncTypeName($this->enabledTypeBefore, $this->enabledTypeAfter); }
/** * {@inheritdoc} */ public function addRootBinding(BindingDescriptor $bindingDescriptor, $flags = 0) { $this->assertPackagesLoaded(); $typeName = $bindingDescriptor->getTypeName(); $typeExists = $this->typeDescriptors->contains($typeName); if (!($flags & self::IGNORE_TYPE_NOT_FOUND) && !$typeExists) { throw NoSuchTypeException::forTypeName($typeName); } if (!($flags & self::IGNORE_TYPE_NOT_ENABLED) && $typeExists && !$this->typeDescriptors->getFirst($typeName)->isEnabled()) { throw TypeNotEnabledException::forTypeName($typeName); } $uuid = $bindingDescriptor->getUuid(); if ($this->bindingDescriptors->contains($uuid)) { throw DuplicateBindingException::forUuid($uuid); } $tx = new Transaction(); try { $syncOp = $this->syncBindingUuid($uuid); $syncOp->takeSnapshot(); $tx->execute($this->loadBindingDescriptor($bindingDescriptor, $this->rootPackage)); $this->assertBindingValid($bindingDescriptor); $tx->execute($this->addBindingDescriptorToPackageFile($bindingDescriptor)); $tx->execute($syncOp); $this->saveRootPackageFile(); $tx->commit(); } catch (Exception $e) { $tx->rollback(); throw $e; } }
/** * {@inheritdoc} */ public function addRootBindingDescriptor(BindingDescriptor $bindingDescriptor, $flags = 0) { $this->assertModulesLoaded(); $typeName = $bindingDescriptor->getTypeName(); $typeExists = $this->typeDescriptors->contains($typeName); if (!($flags & self::IGNORE_TYPE_NOT_FOUND) && !$typeExists) { throw NoSuchTypeException::forTypeName($typeName); } if (!($flags & self::IGNORE_TYPE_NOT_ENABLED) && $typeExists && !$this->typeDescriptors->getFirst($typeName)->isEnabled()) { throw TypeNotEnabledException::forTypeName($typeName); } $uuid = $bindingDescriptor->getUuid(); $exists = $this->bindingDescriptors->contains($uuid); $existsInNonRoot = $exists ? !$this->bindingDescriptors->get($uuid)->getContainingModule() instanceof RootModule : false; // We can only override bindings in the root module if ($existsInNonRoot || $exists && !($flags & self::OVERRIDE)) { throw DuplicateBindingException::forUuid($uuid); } $tx = new Transaction(); try { $syncOp = $this->syncBindingUuid($uuid); $syncOp->takeSnapshot(); $tx->execute($this->loadBindingDescriptor($bindingDescriptor, $this->rootModule)); $this->assertBindingValid($bindingDescriptor); $tx->execute($this->addBindingDescriptorToModuleFile($bindingDescriptor)); $tx->execute($syncOp); $this->saveRootModuleFile(); $tx->commit(); } catch (Exception $e) { $tx->rollback(); throw $e; } }