Example #1
0
 /**
  * 获取一个已注册的服务对象
  *
  * @param string $name
  * @return mixed
  * @throws \Pure\DI\Exception
  */
 public function get($name)
 {
     if ($this->_container->has($name)) {
         return $this->_container->get($name);
     }
     try {
         $object = $this->_provider->get($name);
         $this->_container->set($name, $object);
     } catch (Exception $e) {
         throw new Exception("DI component cannot provide '{$name}' service: {$e->getMessage()}");
     }
     return $object;
 }
Example #2
0
 public function get($name)
 {
     $parameter = $this->has($name) ? parent::get($name) : $name;
     return $this->generate($parameter);
 }