/**
  * returns the requested instance from the scope
  *
  * @param   \ReflectionClass                 $impl      concrete implementation
  * @param   \stubbles\ioc\InjectionProvider  $provider
  * @return  object
  */
 public function getInstance(\ReflectionClass $impl, InjectionProvider $provider)
 {
     $key = $impl->getName();
     if (!isset($this->instances[$key])) {
         $this->instances[$key] = $provider->get();
     }
     return $this->instances[$key];
 }
예제 #2
0
 /**
  * returns the requested instance from the scope
  *
  * @param   \ReflectionClass   $impl      concrete implementation
  * @param   InjectionProvider  $provider
  * @return  mixed
  */
 public function getInstance(\ReflectionClass $impl, InjectionProvider $provider)
 {
     $key = $impl->getName();
     if (isset(self::$instances[$key])) {
         return self::$instances[$key];
     }
     self::$instances[$key] = $provider->get();
     return self::$instances[$key];
 }
예제 #3
0
 /**
  * returns the requested instance from the scope
  *
  * @param   \ReflectionClass                 $impl      concrete implementation
  * @param   \stubbles\ioc\InjectionProvider  $provider
  * @return  object
  * @throws  \RuntimeException
  */
 public function getInstance(\ReflectionClass $impl, InjectionProvider $provider)
 {
     if (null === $this->session) {
         throw new \RuntimeException('Can not create session-scoped instance for ' . $impl->getName() . ', no session set in session scope');
     }
     $key = self::SESSION_KEY . $impl->getName();
     if ($this->session->hasValue($key)) {
         return $this->session->value($key);
     }
     $instance = $provider->get();
     $this->session->putValue($key, $instance);
     return $instance;
 }