Пример #1
0
 /**
  * Attach the Profiler's event listeners.
  *
  * @return void
  */
 public static function attach()
 {
     \Laravel\Profiling\Profiler::attach();
     Event::listen('laravel.mongoquery', function ($db, $sql, $bindings, $time) {
         MongoProfiler::mongo_query($db, $sql, $bindings, $time);
     });
 }
Пример #2
0
 /**
  * Attach the Profiler's event listeners.
  *
  * @return void
  */
 public static function attach()
 {
     // First we'll attach to the query and log events. These allow us to catch
     // all of the SQL queries and log messages that come through Laravel,
     // and we will pass them onto the Profiler for simple storage.
     Event::listen('laravel.log', function ($type, $message) {
         Profiler::log($type, $message);
     });
     Event::listen('laravel.query', function ($sql, $bindings, $time) {
         Profiler::query($sql, $bindings, $time);
     });
     // We'll attach the profiler to the "done" event so that we can easily
     // attach the profiler output to the end of the output sent to the
     // browser. This will display the profiler's nice toolbar.
     Event::listen('laravel.done', function ($response) {
         echo Profiler::render($response);
     });
 }
Пример #3
0
 /**
  * Register the Blade view engine with Laravel.
  *
  * @return void
  */
 public static function sharpen()
 {
     Event::listen(View::engine, function ($view) {
         // The Blade view engine should only handle the rendering of views which
         // end with the Blade extension. If the given view does not, we will
         // return false so the View can be rendered as normal.
         if (!str_contains($view->path, BLADE_EXT)) {
             return;
         }
         $compiled = Blade::compiled($view->path);
         // If the view doesn't exist or has been modified since the last time it
         // was compiled, we will recompile the view into pure PHP from it's
         // Blade representation, writing it to cached storage.
         if (!file_exists($compiled) or Blade::expired($view->view, $view->path)) {
             file_put_contents($compiled, Blade::compile($view));
         }
         $view->path = $compiled;
         // Once the view has been compiled, we can simply set the path to the
         // compiled view on the view instance and call the typical "get"
         // method on the view to evaluate the compiled PHP view.
         return ltrim($view->get());
     });
 }
Пример #4
0
 /**
  * Register a view composer with the Event class.
  *
  * <code>
  *		// Register a composer for the "home.index" view
  *		View::composer('home.index', function($view)
  *		{
  *			$view['title'] = 'Home';
  *		});
  * </code>
  *
  * @param  string|array  $view
  * @param  Closure       $composer
  * @return void
  */
 public static function composer($views, $composer)
 {
     $views = (array) $views;
     foreach ($views as $view) {
         Event::listen("laravel.composing: {$view}", $composer);
     }
 }
Пример #5
0
 /**
  * Register a view composer with the Event class.
  *
  * <code>
  *		// Register a composer for the "home.index" view
  *		View::composer('home.index', function($view)
  *		{
  *			$view['title'] = 'Home';
  *		});
  * </code>
  *
  * @param  string   $view
  * @param  Closure  $composer
  * @return void
  */
 public static function composer($view, $composer)
 {
     Event::listen("laravel.composing: {$view}", $composer);
 }
Пример #6
0
 public static function sharpen()
 {
     Event::listen(View::engine, function ($view) {
         if (!str_contains($view->path, BLADE_EXT)) {
             return;
         }
         $compiled = Blade::compiled($view->path);
         if (!file_exists($compiled) or Blade::expired($view->view, $view->path)) {
             file_put_contents($compiled, Blade::compile($view));
         }
         $view->path = $compiled;
         return ltrim($view->get());
     });
 }