コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function getBindingType($typeName)
 {
     Assert::stringNotEmpty($typeName, 'The type class must be a non-empty string. Got: %s');
     if (!isset($this->types[$typeName])) {
         throw NoSuchTypeException::forTypeName($typeName);
     }
     return $this->types[$typeName];
 }
コード例 #2
0
 /**
  * {@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);
 }
コード例 #3
0
ファイル: NullDiscovery.php プロジェクト: Nyholm/discovery-1
 /**
  * {@inheritdoc}
  */
 public function getBindingType($typeName)
 {
     throw NoSuchTypeException::forTypeName($typeName);
 }
コード例 #4
0
 /**
  * {@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]);
 }
コード例 #5
0
ファイル: JsonDiscovery.php プロジェクト: Nyholm/discovery-1
 /**
  * {@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();
 }
コード例 #6
0
ファイル: JsonDiscovery.php プロジェクト: webmozart/discovery
 /**
  * {@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();
 }