lithium\console\Command::_init PHP Method

_init() protected method

Populates the $response property with a new instance of the Response class passing it configuration and assigns the values from named parameters of the request (if applicable) to properties of the command.
protected _init ( ) : void
return void
    protected function _init()
    {
        parent::_init();
        $this->request = $this->_config['request'];
        if (!is_object($this->request) || !$this->request->params) {
            return;
        }
        $this->response = $this->_config['response'];
        if (!is_object($this->response)) {
            $this->response = $this->_instance('response', $this->response);
        }
        $default = array('command' => null, 'action' => null, 'args' => null);
        $params = array_diff_key((array) $this->request->params, $default);
        foreach ($params as $key => $param) {
            $this->{$key} = $param;
        }
    }

Usage Example

 /**
  * Class initializer. Parses template and sets up params that need to be filled.
  *
  * @return void
  */
 protected function _init()
 {
     parent::_init();
     $this->library = $this->library ?: true;
     $defaults = array('prefix' => null, 'path' => null);
     $this->_library = (array) Libraries::get($this->library) + $defaults;
 }
All Usage Examples Of lithium\console\Command::_init