protected function defaultNotFound() { $mediaType = $this->request->getMediaType(); if ('application/json' === $mediaType || true === $this->isAPI()) { $this->response->headers->set('Content-Type', 'application/json'); echo json_encode(array('code' => 404, 'message' => 'Not found'), JSON_PRETTY_PRINT); } else { parent::defaultNotFound(); } }