/** * Register event listeners */ public function boot() { // Get config (again) $config = $this->app->make('config')->get('freezer::config'); $dir = $config['dir']; // Create caches by listening for the laravel lifecyle response as long as there // is a whitelist if (count($config['whitelist'])) { $lists = $this->app->make('freezer.lists'); $cookies = $this->app->make('cookie'); $queue = $this->app->make('freezer.queue'); $this->app->after(function ($request, $response) use($dir, $lists, $cookies, $queue) { // Iterate through the queue of operations and do clears or rebuilds. Check that // we're not currently fielding a request from Freezer, though. Otherwise infitine // loops if (!preg_match('#' . preg_quote(Facade::USER_AGENT, '#') . '#', $request->header('user-agent'))) { $queue->process(); } // Init create class and check if we should cache this request $create = new Create($response, $dir); $create->conditionallyCache($request, $lists, $cookies); }); } }