Ejemplo n.º 1
0
 public function register(App $glue)
 {
     $glue->singleton('Database\\Connection', function ($glue) {
         $logger = $glue->bound('Psr\\Log\\LoggerInterface') ? $glue->make('Psr\\Log\\LoggerInterface') : null;
         $factory = new ConnectionFactory(null, $logger);
         return $factory->make($glue->config->get('database'));
     });
     $glue->alias('Database\\Connection', 'db');
 }
Ejemplo n.º 2
0
 public function register(App $glue)
 {
     $glue->singleton('League\\Plates\\Engine', function ($glue) {
         if (!$glue->config->exists('plates.path')) {
             // We need a default template folder
             throw new \Exception("You must configure the plates.path");
         }
         $engine = new Engine($glue->config->get('plates.path'));
         // Register some extensions
         $engine->loadExtension($glue->make('Glue\\Plates\\Extensions\\UrlHelpers'));
         return $engine;
     });
     $glue->alias('League\\Plates\\Engine', 'plates');
 }
Ejemplo n.º 3
0
 public function register(App $glue)
 {
     $whoops = new Run();
     $logger = $glue->bound('Psr\\Log\\LoggerInterface') ? $glue->make('Psr\\Log\\LoggerInterface') : null;
     $whoops->pushHandler(new PlainTextHandler($logger));
     if ($glue->config->get('debug', false) !== true) {
         $whoops->pushHandler(new ProductionHandler($logger));
     } else {
         $whoops->pushHandler(new PrettyPageHandler($logger));
     }
     $whoops->register();
     $glue->singleton('Whoops\\Run', function () use($whoops) {
         return $whoops;
     });
 }
Ejemplo n.º 4
0
 public function register(App $glue)
 {
     $glue->singleton('Twig_Environment', function ($glue) {
         if (!$glue->config->exists('twig.path')) {
             // We need a default template folder
             throw new \Exception("You must set the twig.path");
         }
         // Instansiate Twig
         $loader = new Twig_Loader_Filesystem($glue->config->get('twig.path'), $glue->config->get('twig.config', []));
         $environment = new Twig_Environment($loader);
         // Register extensions
         $environment->addExtension($glue->make('Glue\\Twig\\Extensions\\UrlHelpers'));
         return $environment;
     });
     $glue->alias('Twig_Environment', 'twig');
 }