Exemplo 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');
 }
Exemplo n.º 2
0
 public function register(App $app)
 {
     $app->singleton('Glue\\App', function ($app) {
         return $app;
     });
     // Routing
     $app->singleton('Glue\\Router\\Router');
     $app->alias('Glue\\Router\\Router', 'router');
     // HTTP
     $app->singleton('Glue\\Http\\Request', function () {
         return new Request(SymfonyRequest::createFromGlobals());
     });
     $app->alias('Glue\\Http\\Request', 'request');
     $app->singleton('Glue\\Http\\Response');
     $app->alias('Glue\\Http\\Response', 'response');
     $app->singleton('Glue\\Http\\Session');
     $app->alias('Glue\\Http\\Session', 'session');
     // Config
     $app->singleton('Glue\\Config\\Config');
     $app->alias('Glue\\Config\\Config', 'config');
 }
Exemplo n.º 3
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');
 }
Exemplo 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');
 }
Exemplo n.º 5
0
 public function register(App $glue)
 {
     #if (!$glue->config->exists('monolog.path')) {
     #    // No log path set
     #    return;
     #}
     $glue->singleton('Monolog\\Logger', function ($glue) {
         $logLevel = $glue->config->get('monolog.level', Logger::ERROR);
         $logLevel = Logger::toMonologLevel($logLevel);
         $folder = $glue->config->get('monolog.folder');
         $filename = $glue->config->get('monolog.file', 'app.log');
         // create a log channel
         $log = new Logger($glue->config->get('monolog.name', 'glue'));
         $log->pushHandler(new StreamHandler($folder . '/' . $filename, $logLevel));
         return $log;
     });
     $glue->singleton('Psr\\Log\\LoggerInterface', 'Monolog\\Logger');
     $glue->alias('Monolog\\Logger', 'log');
 }