private function refreshState()
 {
     if (null === $this->typeDescriptor || !$this->typeDescriptor->isLoaded()) {
         $this->state = BindingState::TYPE_NOT_FOUND;
     } elseif (!$this->typeDescriptor->isEnabled()) {
         $this->state = BindingState::TYPE_NOT_ENABLED;
     } elseif (count($this->loadErrors) > 0) {
         $this->state = BindingState::INVALID;
     } elseif ($this->containingModule instanceof RootModule) {
         $this->state = BindingState::ENABLED;
     } elseif ($this->containingModule->getInstallInfo()->hasDisabledBindingUuid($this->binding->getUuid())) {
         $this->state = BindingState::DISABLED;
     } else {
         $this->state = BindingState::ENABLED;
     }
 }
 /**
  * {@inheritdoc}
  */
 public function addBinding(Binding $binding)
 {
     $typeName = $binding->getTypeName();
     if (!isset($this->keysByTypeName[$typeName])) {
         throw NoSuchTypeException::forTypeName($typeName);
     }
     if (isset($this->keysByUuid[$binding->getUuid()->toString()])) {
         // Ignore duplicates
         return;
     }
     $key = $this->keysByTypeName[$typeName];
     if (!isset($this->bindingsByKey[$key])) {
         $this->loadBindingsForKey($key);
     }
     $this->initializeBinding($binding);
     $this->keysByUuid[$binding->getUuid()->toString()] = $key;
     $this->bindingsByKey[$key][] = $binding;
     $this->store->set('b:' . $key, $this->bindingsByKey[$key]);
     $this->store->set('::keysByUuid', $this->keysByUuid);
 }
 /**
  * Initializes a binding.
  *
  * @param Binding $binding The binding to initialize.
  *
  * @throws BindingNotAcceptedException If the loaded type does not accept
  *                                     the binding.
  */
 protected function initializeBinding(Binding $binding)
 {
     $binding->initialize($this->getBindingType($binding->getTypeName()));
     $bindingClass = get_class($binding);
     if (!isset($this->initializersByBindingClass[$bindingClass])) {
         $this->initializersByBindingClass[$bindingClass] = array();
         // Find out which initializers accept the binding
         foreach ($this->initializers as $initializer) {
             if ($initializer->acceptsBinding($bindingClass)) {
                 $this->initializersByBindingClass[$bindingClass][] = $initializer;
             }
         }
     }
     // Apply all initializers that we found
     foreach ($this->initializersByBindingClass[$bindingClass] as $initializer) {
         $initializer->initializeBinding($binding);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function addBinding(Binding $binding)
 {
     $uuidString = $binding->getUuid()->toString();
     if (isset($this->bindings[$uuidString])) {
         return;
     }
     $this->initializeBinding($binding);
     $this->bindings[$uuidString] = $binding;
     $this->bindingsByTypeName[$binding->getTypeName()][$uuidString] = $binding;
 }
 /**
  * {@inheritdoc}
  */
 public function addBinding(Binding $binding)
 {
     $typeName = $binding->getTypeName();
     if (!isset($this->keysByTypeName[$typeName])) {
         throw NoSuchTypeException::forTypeName($typeName);
     }
     $key = $this->keysByTypeName[$typeName];
     if (!isset($this->bindingsByKey[$key])) {
         $this->loadBindingsForKey($key);
     }
     $this->initializeBinding($binding);
     $this->bindingsByKey[$key][] = $binding;
     $this->store->set('b:' . $key, $this->bindingsByKey[$key]);
 }
Exemple #6
0
 /**
  * {@inheritdoc}
  */
 public function addBinding(Binding $binding)
 {
     if (null === $this->json) {
         $this->load();
     }
     $typeName = $binding->getTypeName();
     if (!isset($this->json['keysByTypeName'][$typeName])) {
         throw NoSuchTypeException::forTypeName($typeName);
     }
     if (isset($this->json['keysByUuid'][$binding->getUuid()->toString()])) {
         // Ignore duplicates
         return;
     }
     $key = $this->json['keysByTypeName'][$typeName];
     if (!isset($this->bindingsByKey[$key])) {
         $this->loadBindingsForKey($key);
     }
     $this->initializeBinding($binding);
     $this->bindingsByKey[$key][] = $binding;
     $this->json['keysByUuid'][$binding->getUuid()->toString()] = $key;
     $this->json['bindingsByKey'][$key] = serialize($this->bindingsByKey[$key]);
     $this->flush();
 }
 /**
  * {@inheritdoc}
  */
 public function addBinding(Binding $binding)
 {
     $typeName = $binding->getTypeName();
     $this->initializeBinding($binding);
     $this->bindingsByTypeName[$typeName][] = $binding;
 }
 /**
  * {@inheritdoc}
  */
 public function addBinding(Binding $binding)
 {
     if (null === $this->json) {
         $this->load();
     }
     $typeName = $binding->getTypeName();
     if (!isset($this->json['keysByTypeName'][$typeName])) {
         throw NoSuchTypeException::forTypeName($typeName);
     }
     $key = $this->json['keysByTypeName'][$typeName];
     if (!isset($this->bindingsByKey[$key])) {
         $this->loadBindingsForKey($key);
     }
     $this->initializeBinding($binding);
     $this->bindingsByKey[$key][] = $binding;
     $this->json['bindingsByKey'][$key] = serialize($this->bindingsByKey[$key]);
     $this->flush();
 }