/**
  * Compute parameter with class value.
  *
  * @param mixed $parameter
  *
  * @return mixed|object|null
  */
 protected function computeParameterClass($parameter)
 {
     $class = $this->getParameterClass($parameter);
     if (null !== $class) {
         if ($this->container->has($class)) {
             return $this->container->get($class);
         }
         if (false !== $this->resolveUnknownClass && null !== ($instance = $this->container->getDi()->createInstance($class))) {
             return $instance->getOriginalInstance();
         }
     }
     return null;
 }
Exemple #2
0
 /**
  * Constructor.
  *
  * @param ContainerInterface $container
  */
 public function __construct(ContainerInterface $container = null)
 {
     $this->container = $container ?: new Container(null, $this);
     $this->resolver = $this->container->getParameterBag()->getResolver();
     $this->injector = new Injector($this->container);
 }