3 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
4 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
6 * Licensed under The MIT License
7 * For full copyright and license information, please see the LICENSE.txt
8 * Redistributions of files must retain the above copyright notice.
10 * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
11 * @link http://cakephp.org CakePHP(tm) Project
13 * @license http://www.opensource.org/licenses/mit-license.php MIT License
15 namespace App\Controller;
17 use Cake\Controller\Controller;
21 * Application Controller
23 * Add your application-wide methods in the class below, your controllers
26 * @link http://book.cakephp.org/3.0/en/controllers.html#the-app-controller
28 class AppController extends Controller
31 * Initialization hook method.
33 * Use this method to add common initialization code like loading components.
35 * e.g. `$this->loadComponent('Security');`
39 public function initialize()
43 $this->loadComponent('RequestHandler');
44 $this->loadComponent('Flash');
47 * Enable the following components for recommended CakePHP security settings.
48 * see http://book.cakephp.org/3.0/en/controllers/components/security.html
50 //$this->loadComponent('Security');
51 //$this->loadComponent('Csrf');
55 * Before render callback.
57 * @param \Cake\Event\Event $event The beforeRender event.
58 * @return \Cake\Network\Response|null|void
60 public function beforeRender(Event $event)
62 if (!array_key_exists('_serialize', $this->viewVars) &&
63 in_array($this->response->type(), ['application/json', 'application/xml'])
65 $this->set('_serialize', true);