Hi everyone! I have a question: how can I stop/interrupt beforeExecuteRoute handling? It is always continue handling and run the action. Example:
//Base controller for some actions
class AController extends BaseController
{
public function beforeExecuteRoute($dispatcher)
{
$action = $this->dispatcher->getActionName();
if ($action !== 'token') {
$this->token = $this->dispatcher->getParam('token');
if (!$this->token || !$this->isAvailableToken($this->token)) {
$this->view->disable();
$this->response->setStatusCode(401, "Unauthorized");
$this->response->setContentType('application/json', 'UTF-8');
$this->response->setJsonContent(array(
'status' => 401,
'message' => 'Your token in not available',
'token' => '',
));
return $this->response->send(); //does not work, continue to run action
//return false; //does not work, continue to run action
//return $this->response->redirect('api/auth'); //work but It is not my case
//return $this->response->send();
//exit; //work, but is not best solution
}
}
return true;
}
}
class WController extends AController {
public function beforeExecuteRoute($dispatcher) {
parent::beforeExecuteRoute($dispatcher);
//I do not want to run this, parent beforeExecuteRoute have to be interrupted
/*
* some logic here
*/
}
public function indexAction()
{
echo 'it will be called';
}
}