Hi, i'm trying to response with a json when, inside the beforeExecuteRoute, a condition is not satisfied. I not able to stop the execution and sent a json response. Now i'm doing this:
public function beforeExecuteRoute()
{
$this->view->disable();
$allowedIp = $this->getAllowedServer();
foreach ($allowedIp as $key => $ip) {
if ($_SERVER['SERVER_ADDR'] === $ip){
return true;
}
}
$this->response->setContentType('application/json');
$this->response->setJsonContent(array(
'status' => 'error',
'message' => 'Access denied'
));
return $this->response;
}
it not work with 'exit' either 'retunr false'
Do you have some suggestions?
Thank you.