Skip to content

Commit

Permalink
v1.0.6 Use extend dispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Dolgov_M committed Feb 16, 2018
1 parent 358096a commit d1acd9e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "bi0r0b0t/silex-pinba-provider",
"description": "Provide PinbaBundle for Silex",
"minimum-stability": "stable",
"version": "1.0.5",
"version": "1.0.6",
"license": "MIT",
"authors": [
{
Expand Down
32 changes: 10 additions & 22 deletions src/SilexPinbaProvider/SilexPinbaProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
use Intaro\PinbaBundle\Logger\DbalLogger;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Silex\Api\BootableProviderInterface;
use Silex\Application;
use SilexPinbaProvider\Twig\TimedTwigEnvironment;

class SilexPinbaProvider implements ServiceProviderInterface, BootableProviderInterface
class SilexPinbaProvider implements ServiceProviderInterface
{

/**
Expand Down Expand Up @@ -79,27 +78,16 @@ public function register(Container $app)
}
return $twig;
});
}

/**
* Bootstraps the application.
*
* This method is called after all services are registered
* and should be used for "dynamic" configuration (whenever
* a service must be requested).
* @param Application $app
*/
public function boot(Application $app)
{
if (!function_exists('pinba_script_name_set') || PHP_SAPI === 'cli' || !$app['intaro_pinba.script_name_configure.enable']) {
return;
}
/**
* @var $dispatcher \Symfony\Component\EventDispatcher\EventDispatcherInterface
*/
$dispatcher = $app['dispatcher'];
$dispatcher->addListener('kernel.request', array($app['intaro_pinba.script_name_configure.listener'], 'onRequest'));

if (PHP_SAPI !== 'cli') {
$app->extend('dispatcher', function ($dispatcher) use ($app) {
/**
* @var $dispatcher \Symfony\Component\EventDispatcher\EventDispatcherInterface
*/
$dispatcher->addListener('kernel.request', array($app['intaro_pinba.script_name_configure.listener'], 'onRequest'));
return $dispatcher;
});
}
}

}

0 comments on commit d1acd9e

Please sign in to comment.