afterFilter() public method

Called after the controller action is run and rendered.
public afterFilter ( Cake\Event\Event $event ) : Response | null
$event Cake\Event\Event An Event instance
return Cake\Network\Response | null
 /**
  * Generate the response using the controller object.
  *
  * @param string $template The template to render.
  * @return void
  */
 protected function _outputMessage($template)
 {
     try {
         $this->controller->render($template);
         $event = new Event('Controller.shutdown', $this->controller);
         $this->controller->afterFilter($event);
         $this->controller->response->send();
     } catch (MissingViewException $e) {
         $attributes = $e->getAttributes();
         if (isset($attributes['file']) && strpos($attributes['file'], 'error500') !== false) {
             $this->_outputMessageSafe('error500');
         } else {
             $this->_outputMessage('error500');
         }
     } catch (\Exception $e) {
         $this->_outputMessageSafe('error500');
     }
 }
Example #2
-1
 /**
  * Generate the response using the controller object.
  *
  * @param string $template The template to render.
  * @return \Cake\Network\Response A response object that can be sent.
  */
 protected function _outputMessage($template)
 {
     try {
         $this->controller->render($template);
         $event = new Event('Controller.shutdown', $this->controller);
         $this->controller->afterFilter($event);
         return $this->controller->response;
     } catch (MissingTemplateException $e) {
         $attributes = $e->getAttributes();
         if (isset($attributes['file']) && strpos($attributes['file'], 'error500') !== false) {
             return $this->_outputMessageSafe('error500');
         }
         return $this->_outputMessage('error500');
     } catch (MissingPluginException $e) {
         $attributes = $e->getAttributes();
         if (isset($attributes['plugin']) && $attributes['plugin'] === $this->controller->plugin) {
             $this->controller->plugin = null;
         }
         return $this->_outputMessageSafe('error500');
     } catch (\Exception $e) {
         return $this->_outputMessageSafe('error500');
     }
 }