[ 'enableBeforeRedirect' => false ], 'Security', ]; /** * beforeFilter * * @return void */ public function beforeFilter(Event $event) { if ($this->request->getParam('action') !== 'securePost') { $this->getEventManager()->off($this->Security); } } /** * Index method. * * @param string $layout * @return void */ public function index($layout = 'default') { $this->Flash->error('An error message'); $this->response = $this->response->withCookie(new Cookie('remember_me', 1)); $this->set('test', 'value'); $this->viewBuilder()->setLayout($layout); } /** * Sets a flash message and redirects (no rendering) * * @return \Cake\Http\Response */ public function flashNoRender() { $this->Flash->error('An error message'); return $this->redirect(['action' => 'index']); } /** * Stub get method * * @return void */ public function get() { // Do nothing. } /** * Post endpoint for integration testing with security component. * * @return void */ public function securePost() { return $this->response->withStringBody('Request was accepted'); } public function file() { return $this->response->withFile(__FILE__); } public function header() { return $this->getResponse()->withHeader('X-Cake', 'custom header'); } public function empty_response() { return $this->getResponse()->withStringBody(''); } public function stacked_flash() { $this->Flash->error('Error 1'); $this->Flash->error('Error 2'); $this->Flash->success('Success 1', ['key' => 'custom']); $this->Flash->success('Success 2', ['key' => 'custom']); return $this->getResponse()->withStringBody(''); } }