Ejemplo n.º 1
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $in_app_file = $this->app['path'] . '/config/packages/' . $this->packageName . '/profiler.php';
     Config::init(file_exists($in_app_file) ? $in_app_file : null);
     // Stopwatch - must be registered so the application doesn't fail if the profiler is disabled
     $this->app['stopwatch'] = $this->app->share(function () {
         return new Stopwatch(defined('LARAVEL_START') ? LARAVEL_START * 1000 : null);
     });
     // Must be enabled for the current environment
     if (!in_array($this->app->environment(), Config::get('environments'))) {
         return;
     }
     // Time collection is done anyway
     $this->collectors = new DataContainer();
     $this->collectors->add(new TimeDataCollector());
     // this will be executed anyway
     $this->app->after(array($this, 'onCloseHeaders'));
     $this->app['stopwatch']->start('Application initialisation.', 'section');
     // Laravel 4.1 has a new routing layer, some stuff is different
     $is_4_0 = class_exists('\\Illuminate\\Routing\\Controllers\\Controller');
     // Collect
     $this->collectors->add(new MonologDataCollector())->add(new FilesDataCollector())->add(new DatabaseDataCollector())->add(new VariablesDataCollector())->add($is_4_0 ? new RouterDataCollector() : new Router41DataCollector());
     $this->app->before(array($this->collectors, 'register'));
     // Populate timeline
     if ($this->app->isBooted()) {
         $this->onBooting();
     } else {
         $this->app->booting(array($this, 'onBooting'));
     }
     $this->app->booted(array($this, 'onBooted'));
     $this->app->before(array($this, 'onBefore'));
     $this->app->after(array($this, 'onAfter'));
 }