bootstrapCli(); } /* * Only try to load DebugKit in development mode * Debug Kit should not be installed on a production system */ if (Configure::read('debug')) { $this->addPlugin(\DebugKit\Plugin::class); } // Load more plugins here } /** * Setup the middleware queue your application will use. * * @param \Cake\Http\MiddlewareQueue $middlewareQueue The middleware queue to setup. * @return \Cake\Http\MiddlewareQueue The updated middleware queue. */ public function middleware($middlewareQueue) { //$csrf = new CsrfProtectionMiddleware(); // Token check will be skipped when callback returns `true`. /*$csrf->whitelistCallback(function ($request) { // Skip token check for API URLs. //if ($request->getParam('prefix') === 'api') { if($request->getAttribute('base') === 'TransactionJsonRequestHandler') { return true; } }); */ // Ensure routing middleware is added to the queue before CSRF protection middleware. //$middlewareQueue->; $middlewareQueue // ->add($csrf) // Catch any exceptions in the lower layers, // and make an error page/response ->add(new ErrorHandlerMiddleware(null, Configure::read('Error'))) // Handle plugin/theme assets like CakePHP normally does. ->add(new AssetMiddleware([ 'cacheTime' => Configure::read('Asset.cacheTime') ])) // Add routing middleware. // If you have a large number of routes connected, turning on routes // caching in production could improve performance. For that when // creating the middleware instance specify the cache config name by // using it's second constructor argument: // `new RoutingMiddleware($this, '_cake_routes_')` ->add(new RoutingMiddleware($this)); return $middlewareQueue; } /** * @return void */ protected function bootstrapCli() { try { $this->addPlugin('Bake'); } catch (MissingPluginException $e) { // Do not halt if the plugin is missing } // Load more plugins here } }