public static function __initialize() { $app = static::instance(); $uri = Url::current()->uri(); $css = ['css/bootstrap.css', 'css/bootstrap-responsive.css']; $js = ['js/jquery.js', 'js/bootstrap.js']; $app->response = Response::instance(); $app->session = Session::instance(); $app->cache = Datastore::instance(); $app->css = Asset::collection($css); $app->js = Asset::collection($js); // If there is no url, then we're on the home page. trim($uri, '/') == '' and $uri = '@@HOME'; if ($page = Model\Page::findOneByUri($uri)) { $app->response->setBody($page->title); return; } try { Controller::instance()->dispatch($uri, $app->response); return; } catch (HttpException $e) { if (!($page = Model\Page::findOneByUri($uri = '@@404'))) { // Fallback to system handling. throw new HttpException(404, 'Page Not Found'); } $app->response->setStatus(404); $app->response->setBody($page->title); return; } }
<?php namespace Application; return ['form.csrf' => function (\Nerd\Form $form, $state) { \Nerd\Session::instance()->set('application.csrf', $state); }];