Пример #1
0
 private function resolveDefinition(DefinitionHelper $value, ArrayDefinition $definition, $key)
 {
     try {
         return $this->definitionResolver->resolve($value->getDefinition(''));
     } catch (DependencyException $e) {
         throw $e;
     } catch (Exception $e) {
         throw new DependencyException(sprintf('Error while resolving %s[%s]. %s', $definition->getName(), $key, $e->getMessage()), 0, $e);
     }
 }
Пример #2
0
 /**
  * Define an object or a value in the container
  *
  * @param string                 $name  Entry name
  * @param mixed|DefinitionHelper $value Value, use definition helpers to define objects
  */
 public function set($name, $value)
 {
     // Clear existing entry if it exists
     if (array_key_exists($name, $this->singletonEntries)) {
         unset($this->singletonEntries[$name]);
     }
     if ($value instanceof DefinitionHelper) {
         $definition = $value->getDefinition($name);
     } else {
         $definition = new ValueDefinition($name, $value);
     }
     $this->definitionManager->addDefinition($definition);
 }