public function run($sAction, $aParams = array()) { $sMethod = 'action' . $sAction; if (method_exists($this, $sMethod)) { $aFilters = $this->filters(); $aActionFilters = array(); if (is_array($aFilters) && count($aFilters)) { foreach ($aFilters as $key => $actions) { if (is_array($actions)) { foreach ($actions as $action) { if (strcasecmp($sAction, $action) === 0) { $aActionFilters[] = $key; break; } } } else { if (strcasecmp($sAction, $actions) === 0) { $aActionFilters[] = $key; } } } if (count($aActionFilters)) { $oFilterChain = new FilterChain(); foreach ($aActionFilters as $filter) { $sFilterClass = $filter . 'Filter'; $oFilterChain->registerFilter(new $sFilterClass()); } $oFilterChain->process(); } } $oAction = new Action($this, $sAction, $aParams); return $oAction->run(); } else { $this->redirect('/site/404'); } }
/** * Calls the action specified in the request object and returns a response * * @return Response */ public function run() { $this->initialize(); $action = $this->getActionName(); if (!$this->actionExists($action)) { throw new ActionNotFound($action); } $this->session->start(); $this->flash = isset($this->session['__FLASH__']) ? $this->session['__FLASH__'] : new Flash(); $beforeResult = $this->beforeFilters->process($this, $action, 'before'); $this->aroundFilters->process($this, $action, 'before'); if ($beforeResult !== false && !$this->performedRespond) { $content = $this->{$action}(); if (!$this->performedRespond) { $this->respond($content); } } $this->aroundFilters->process($this, $action, 'after'); $this->afterFilters->process($this, $action, 'after'); $this->flash->discard(); $this->session['__FLASH__'] = $this->flash; $this->session->store(); return $this->response; }
/** * Performs action * * @access private */ private function perform($action, $filters) { $fc = new FilterChain(); $fc->addFilters($filters); $aw = new ActionWrapper($action[0], $action[1]); $fc->process($this->context, $aw); return $aw->mResult; }