I've the following controller
class TitleController extends AbstractActionController {
public function showAllTitleAction() {
//Here I've some service that fetch entries from db
$data = $this->getData();
if (count($data) == 0) {
//If data is empty, get 404 code for SEO reasons.
$this->getResponse()->setStatusCode(404);
}
//Although data is empty, go on creating the specific view for this controller
$viewModel = new ViewModel($data);
$viewModel->setTemplate('application/title/template');
return $viewModel;
}
}
When I give 404 error in the controller, my request is intercepted and I get the default 404 error page. But I just want to change HTTP status code, not the content. (I'll show a friendly message in the output)
How can I prevent my request to be intercepted by the default 404 page?
Thanks.