request->param('action') !== 'securePost') { $this->eventManager()->off($this->Security); } } /** * Index method. * * @param string $layout * @return void */ public function index($layout = 'default') { $this->Flash->error('An error message'); $this->response->cookie([ 'name' => 'remember_me', 'value' => 1 ]); $this->set('test', 'value'); $this->viewBuilder()->setLayout($layout); } /** * Sets a flash message and redirects (no rendering) * * @return \Cake\Network\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() { $this->response->body('Request was accepted'); return $this->response; } public function file() { $this->response->file(__FILE__); return $this->response; } }