Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function buildDiscovery()
 {
     $this->assertModulesLoaded();
     $this->emitWarningForDuplicateTypes();
     $this->emitWarningForInvalidBindings();
     if ($this->discovery->hasBindings() || $this->discovery->hasBindingTypes()) {
         throw new DiscoveryNotEmptyException('The discovery is not empty.');
     }
     $tx = new Transaction();
     try {
         foreach ($this->typeDescriptors->toArray() as $typeName => $descriptorsByModule) {
             foreach ($descriptorsByModule as $typeDescriptor) {
                 if ($typeDescriptor->isEnabled()) {
                     $tx->execute($this->addBindingType($typeDescriptor));
                 }
             }
         }
         foreach ($this->bindingDescriptors->toArray() as $bindingDescriptor) {
             if ($bindingDescriptor->isEnabled()) {
                 $tx->execute($this->addBinding($bindingDescriptor));
             }
         }
         $tx->commit();
     } catch (Exception $e) {
         $tx->rollback();
         throw $e;
     }
 }
 /**
  * {@inheritdoc}
  */
 public function buildDiscovery()
 {
     $this->assertPackagesLoaded();
     $this->emitWarningForDuplicateTypes();
     $this->emitWarningForInvalidBindings();
     if (count($this->discovery->getBindings()) > 0 || count($this->discovery->getDefinedTypes()) > 0) {
         throw new DiscoveryNotEmptyException('The discovery is not empty.');
     }
     $tx = new Transaction();
     try {
         foreach ($this->typeDescriptors->toArray() as $typeName => $typesByPackage) {
             foreach ($typesByPackage as $typeDescriptor) {
                 if ($typeDescriptor->isEnabled()) {
                     $tx->execute($this->defineType($typeDescriptor));
                 }
             }
         }
         foreach ($this->bindingDescriptors->toArray() as $bindingDescriptor) {
             if ($bindingDescriptor->isEnabled()) {
                 $tx->execute($this->bind($bindingDescriptor));
             }
         }
         $tx->commit();
     } catch (Exception $e) {
         $tx->rollback();
         throw $e;
     }
 }
 /**
  * {@inheritdoc}
  */
 public function removeRootPathMappings(Expression $expr)
 {
     $this->assertMappingsLoaded();
     $tx = new Transaction();
     try {
         foreach ($this->getRootPathMappings() as $mapping) {
             if ($mapping->match($expr)) {
                 $syncOp = $this->syncRepositoryPath($mapping->getRepositoryPath());
                 $syncOp->takeSnapshot();
                 $tx->execute($this->unloadPathMapping($mapping));
                 $tx->execute($this->removePathMappingFromPackageFile($mapping->getRepositoryPath()));
                 $tx->execute($syncOp);
             }
         }
         $this->saveRootPackageFile();
         $tx->commit();
     } catch (Exception $e) {
         $tx->rollback();
         throw $e;
     }
     $this->removeResolvedConflicts();
 }