/** * Overriding parent * * @param string $name * @return mixed */ public function __get($name) { // View if ($name == 'view') { return $this->_controllerInstance->getView(); } // Request if ($name == 'request') { return $this->_controllerInstance->getRequest(); } // Response if ($name == 'response') { return $this->_controllerInstance->getResponse(); } // POST if ($name == 'post') { return $this->_controllerInstance->getRequest()->getPost(); } // GET if ($name == 'query') { return $this->_controllerInstance->getRequest()->getQuery(); } // URL parameters if ($name == 'params') { return $this->_controllerInstance->getRequest()->getParams(); } // application env if ($name == 'appEnv') { return $this->_controllerInstance->getAppEnv(); } parent::__get($name); }
/** * Overriding parent * * @param string $name * @return mixed */ public function __get($name) { if ($name == 'session') { if ($this->_session === null) { $req = $this->request; Loader::load('Session', 'core'); $ns = $req->getController(); $subdir = str_replace('/', '_', $req->getControllerSubDirectory()); if ($subdir != '') { $ns = $subdir . '_' . $ns; } $this->_session = new Session($ns); } return $this->_session; } if ($name == 'post') { if (!array_key_exists($name, $this->_caches)) { $this->_caches[$name] = $this->request->getPost(); } return $this->_caches[$name]; } if ($name == 'query') { if (!array_key_exists($name, $this->_caches)) { $this->_caches[$name] = $this->request->getQuery(); } return $this->_caches[$name]; } if ($name == 'params') { if (!array_key_exists($name, $this->_caches)) { $this->_caches[$name] = $this->request->getParams(); } return $this->_caches[$name]; } if ($name == 'controller') { if (!array_key_exists($name, $this->_caches)) { $this->_caches[$name] = $this->request->getController(); } return $this->_caches[$name]; } if ($name == 'action') { if (!array_key_exists($name, $this->_caches)) { $this->_caches[$name] = $this->request->getAction(); } return $this->_caches[$name]; } return parent::__get($name); }