/**
  * Loads the binding descriptor.
  *
  * @param Module                     $containingModule The module that
  *                                                     contains the
  *                                                     descriptor.
  * @param BindingTypeDescriptor|null $typeDescriptor   The type descriptor.
  *
  * @throws AlreadyLoadedException If the descriptor is already loaded.
  */
 public function load(Module $containingModule, BindingTypeDescriptor $typeDescriptor = null)
 {
     if (null !== $this->state) {
         throw new AlreadyLoadedException('The binding descriptor is already loaded.');
     }
     $this->loadErrors = array();
     if ($typeDescriptor && $typeDescriptor->isLoaded() && $typeDescriptor->isEnabled()) {
         try {
             $this->binding->initialize($typeDescriptor->getType());
         } catch (Exception $e) {
             $this->loadErrors[] = $e;
         }
     }
     $this->containingModule = $containingModule;
     $this->typeDescriptor = $typeDescriptor;
     $this->refreshState();
 }
 private function syncTypeName(BindingTypeDescriptor $enabledTypeBefore = null, BindingTypeDescriptor $enabledTypeAfter = null)
 {
     if ($enabledTypeBefore && !$enabledTypeAfter) {
         $this->discovery->removeBindingType($this->typeName);
     } elseif (!$enabledTypeBefore && $enabledTypeAfter) {
         $this->discovery->addBindingType($enabledTypeAfter->getType());
     } elseif ($enabledTypeBefore !== $enabledTypeAfter) {
         $this->discovery->removeBindingType($this->typeName);
         $this->discovery->addBindingType($enabledTypeAfter->getType());
     }
 }
 private function typesEqual(BindingTypeDescriptor $descriptor1, BindingTypeDescriptor $descriptor2)
 {
     return $descriptor1->getTypeName() === $descriptor2->getTypeName() && $descriptor1->getDescription() === $descriptor2->getDescription() && $descriptor1->getParameterDescriptions() === $descriptor2->getParameterDescriptions() && $descriptor1->getType()->getParameters() === $descriptor2->getType()->getParameters();
 }
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $this->discovery->addBindingType($this->typeDescriptor->getType());
 }