public function __construct($action = null, $params = array()) { $this->name = str_replace('controller', '', strtolower(get_class($this))); $this->action = $action; $this->params = $params; if (!$this->Request()->isAjax()) { $this->Layout = new Layout($this->layout); $this->Layout->setController($this); } else { $this->Layout = null; } $this->View = new View($this->name . '/' . InflectionComponent::unCamelcase($this->action, '-'), $this->Layout); $this->View->setController($this); $this->View->setAutoRender(true); $this->Request = $this->Request(); }