/** * @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'); }
/** * @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; }
/** * @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; }
/** * @param $name * * @return object */ public function __get($name) { return $this->container->singleton($name); }