Created
October 12, 2014 08:45
-
-
Save ogabrielsantos/084ee93474c6f5ce9971 to your computer and use it in GitHub Desktop.
POST/REDIRECT/GET para uso no CakePHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // POST | |
| if ($this->request->is('post') || $this->request->is('put')) { | |
| $uniqId = uniqid(); | |
| $this->Session->write('Search.' . $uniqId, json_encode($this->request->data)); | |
| // REDIRECT | |
| return $this->redirect('index/search:' . $uniqId); | |
| // GET | |
| } elseif (isset($this->request->params['named']['search'])) { | |
| $data = $this->Session->read('Search.' . $this->request->params['named']['search']); | |
| if (!$data) { | |
| return $this->redirect('index'); | |
| } | |
| $this->request->data = json_decode($data, true); | |
| // Lógica de paginação dos resultados | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment