get() public method

Resolves the service based on its configuration
public get ( string $_name, array $parameters = [] ) : mixed
$_name string
$parameters array
return mixed
Exemplo n.º 1
0
 /**
  * Magic method __get
  *
  * @param string $name
  *
  * @return mixed
  * @throws \ManaPHP\Component\Exception
  */
 public function __get($name)
 {
     if ($this->_dependencyInjector === null) {
         $this->_dependencyInjector = Di::getDefault();
     }
     if ($name === 'persistent') {
         $getParameter = [get_class($this), $this->_dependencyInjector];
         $this->{'persistent'} = $this->_dependencyInjector->get('sessionBag', $getParameter);
     } else {
         $this->{$name} = $this->_dependencyInjector->{$name};
         if ($this->{$name} === null) {
             trigger_error('Access to undefined property `' . $name . '` of `' . get_called_class() . '`.');
         }
     }
     return $this->{$name};
 }