Example #1
0
 protected static function load(array $values)
 {
     $container = new static($values);
     $container['config_path'] = CACHE_DIR . 'config.php';
     $container['grav'] = $container;
     $container['events'] = function ($c) {
         return new EventDispatcher();
     };
     $container['uri'] = function ($c) {
         return new Uri($c);
     };
     $container['config'] = function ($c) {
         return Config::instance($c);
     };
     $container['cache'] = function ($c) {
         return new Cache($c);
     };
     $container['plugins'] = function ($c) {
         return new Plugins($c);
     };
     $container['themes'] = function ($c) {
         return new Themes($c);
     };
     $container['twig'] = function ($c) {
         return new Twig($c);
     };
     $container['taxonomy'] = function ($c) {
         return new Taxonomy($c);
     };
     $container['pages'] = function ($c) {
         return new Page\Pages($c);
     };
     $container['assets'] = function ($c) {
         return new Assets();
     };
     $container['page'] = function ($c) {
         $page = $c['pages']->dispatch($c['uri']->route());
         if (!$page || !$page->routable()) {
             $event = $c->fireEvent('onPageNotFound');
             if (isset($event->page)) {
                 $page = $event->page;
             } else {
                 throw new \RuntimeException('Page Not Found', 404);
             }
         }
         return $page;
     };
     $container['output'] = function ($c) {
         return $c['twig']->processSite($c['uri']->extension());
     };
     $container['browser'] = function ($c) {
         return new Browser();
     };
     $container->register(new StreamsServiceProvider());
     return $container;
 }