Exemplo n.º 1
0
 /**
  * @param Container $Container
  */
 public function __construct(Container $Container)
 {
     $this->container = $Container;
     $this->curl = $Container->singleton('Curl');
     $this->db = $Container->singleton('Db');
     $this->sql = $Container->singleton('Sql');
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function __get($name)
 {
     $val = parent::__get($name);
     if (!is_object($val) and $this->container->isInstantiable($name)) {
         $val = $this->container->singleton($name);
         $this->set($name, $val);
     }
     return $val;
 }
Exemplo n.º 3
0
 /**
  * @param $name
  *
  * @return IConfig|IEntity|IInput|IOutput|IRenderer|IRole|IRouter
  */
 public function __get($name)
 {
     $type = $this->getType();
     $interface_name = $this->getInterface();
     if ($this->container->isInstantiable($name . $type)) {
         $class = $name . $type;
     } elseif ($this->container->isInstantiable($name)) {
         $class = $name;
     } else {
         throw new InvalidArgumentException("Param \$name:'{$name}' is not a valid {$type} class.");
     }
     $obj = $this->container->singleton($class);
     if (!$obj instanceof $interface_name) {
         throw new UnexpectedValueException("Class:'{$class}' must implement {$interface_name}.");
     }
     $this->{$name} = $obj;
     return $obj;
 }
Exemplo n.º 4
0
 /**
  * @param $name
  *
  * @return object
  */
 public function __get($name)
 {
     return $this->container->singleton($name);
 }