Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function register(Application $app)
 {
     $app['dump'] = $app->protect(function ($var) use($app) {
         if (!$app['debug']) {
             return;
         }
         $app['dumper']->dump($app['dumper.cloner']->cloneVar($var));
     });
     VarDumper::setHandler(function ($var) use($app) {
         /*
          * Referencing $app['dump'] in anonymous function
          * so the closure can be replaced in $app without
          * breaking the reference here.
          */
         return $app['dump']($var);
     });
     $app['dumper'] = $app->share(function ($app) {
         return PHP_SAPI === 'cli' ? $app['dumper.cli'] : $app['dumper.html'];
     });
     $app['dumper.cli'] = $app->share(function () {
         return new CliDumper();
     });
     $app['dumper.html'] = $app->share(function () {
         return new HtmlDumper();
     });
     $app['dumper.cloner'] = $app->share(function () {
         $cloner = new VarCloner();
         $cloner->addCasters(Caster\FilesystemCasters::getCasters());
         return $cloner;
     });
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function register(Application $app)
 {
     $app['dump'] = $app->protect(function ($var) use($app) {
         $app['dumper']->dump($app['dumper.cloner']->cloneVar($var));
     });
     VarDumper::setHandler($app['dump']);
     $app['dumper'] = $app->share(function ($app) {
         return PHP_SAPI === 'cli' ? $app['dumper.cli'] : $app['dumper.html'];
     });
     $app['dumper.cli'] = $app->share(function () {
         return new CliDumper();
     });
     $app['dumper.html'] = $app->share(function () {
         return new HtmlDumper();
     });
     $app['dumper.cloner'] = $app->share(function () {
         $cloner = new VarCloner();
         $cloner->addCasters(Caster\FilesystemCasters::getCasters());
         return $cloner;
     });
 }