mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-09 11:03:17 +00:00
Add WebProfilerServiceProvider to inject Ajax profiler
- Silex provider implements feature, but only in Silex 2.0 compatible branch
This commit is contained in:
@@ -18,7 +18,6 @@ use Alchemy\Phrasea\Application\Helper\AclAware;
|
|||||||
use Alchemy\Phrasea\Application\Helper\ApplicationBoxAware;
|
use Alchemy\Phrasea\Application\Helper\ApplicationBoxAware;
|
||||||
use Alchemy\Phrasea\Application\Helper\AuthenticatorAware;
|
use Alchemy\Phrasea\Application\Helper\AuthenticatorAware;
|
||||||
use Alchemy\Phrasea\Authorization\AuthorizationServiceProvider;
|
use Alchemy\Phrasea\Authorization\AuthorizationServiceProvider;
|
||||||
use Alchemy\Phrasea\Cache\Manager;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Subscriber\BasketSubscriber;
|
use Alchemy\Phrasea\Core\Event\Subscriber\BasketSubscriber;
|
||||||
use Alchemy\Phrasea\Core\Event\Subscriber\BridgeSubscriber;
|
use Alchemy\Phrasea\Core\Event\Subscriber\BridgeSubscriber;
|
||||||
use Alchemy\Phrasea\Core\Event\Subscriber\ExportSubscriber;
|
use Alchemy\Phrasea\Core\Event\Subscriber\ExportSubscriber;
|
||||||
@@ -84,7 +83,6 @@ use Alchemy\Phrasea\Twig\Fit;
|
|||||||
use Alchemy\Phrasea\Twig\JSUniqueID;
|
use Alchemy\Phrasea\Twig\JSUniqueID;
|
||||||
use Alchemy\Phrasea\Twig\PhraseanetExtension;
|
use Alchemy\Phrasea\Twig\PhraseanetExtension;
|
||||||
use Alchemy\Phrasea\Utilities\CachedTranslator;
|
use Alchemy\Phrasea\Utilities\CachedTranslator;
|
||||||
use Dflydev\Silex\Provider\DoctrineOrm\DoctrineOrmServiceProvider;
|
|
||||||
use Doctrine\Common\EventManager;
|
use Doctrine\Common\EventManager;
|
||||||
use Doctrine\DBAL\Event\ConnectionEventArgs;
|
use Doctrine\DBAL\Event\ConnectionEventArgs;
|
||||||
use Doctrine\DBAL\Events;
|
use Doctrine\DBAL\Events;
|
||||||
|
@@ -18,6 +18,7 @@ use Alchemy\Phrasea\Core\Event\Subscriber\BridgeExceptionSubscriber;
|
|||||||
use Alchemy\Phrasea\Core\Event\Subscriber\FirewallSubscriber;
|
use Alchemy\Phrasea\Core\Event\Subscriber\FirewallSubscriber;
|
||||||
use Alchemy\Phrasea\Core\Event\Subscriber\JsonRequestSubscriber;
|
use Alchemy\Phrasea\Core\Event\Subscriber\JsonRequestSubscriber;
|
||||||
use Alchemy\Phrasea\Core\Event\Subscriber\DebuggerSubscriber;
|
use Alchemy\Phrasea\Core\Event\Subscriber\DebuggerSubscriber;
|
||||||
|
use Alchemy\Phrasea\Core\Provider\WebProfilerServiceProvider as PhraseaWebProfilerServiceProvider;
|
||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
use Monolog\Processor\WebProcessor;
|
use Monolog\Processor\WebProcessor;
|
||||||
use Silex\Provider\WebProfilerServiceProvider;
|
use Silex\Provider\WebProfilerServiceProvider;
|
||||||
@@ -63,6 +64,9 @@ return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) {
|
|||||||
$app->register($p = new WebProfilerServiceProvider(), [
|
$app->register($p = new WebProfilerServiceProvider(), [
|
||||||
'profiler.cache_dir' => $app['cache.path'].'/profiler',
|
'profiler.cache_dir' => $app['cache.path'].'/profiler',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$app->register(new PhraseaWebProfilerServiceProvider());
|
||||||
|
|
||||||
$app->mount('/_profiler', $p);
|
$app->mount('/_profiler', $p);
|
||||||
|
|
||||||
if ($app['phraseanet.configuration-tester']->isInstalled()) {
|
if ($app['phraseanet.configuration-tester']->isInstalled()) {
|
||||||
|
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Core\Provider;
|
||||||
|
|
||||||
|
use Silex\Application;
|
||||||
|
use Silex\ServiceProviderInterface;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\DataCollector\AjaxDataCollector;
|
||||||
|
|
||||||
|
class WebProfilerServiceProvider implements ServiceProviderInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers services on the given app.
|
||||||
|
*
|
||||||
|
* This method should only be used to configure services and parameters.
|
||||||
|
* It should not get services.
|
||||||
|
*/
|
||||||
|
public function register(Application $app)
|
||||||
|
{
|
||||||
|
if (class_exists('Symfony\Bundle\FrameworkBundle\DataCollector\AjaxDataCollector')) {
|
||||||
|
$app['data_collector.templates'] = $app->extend('data_collector.templates', function (array $templates) {
|
||||||
|
$templates[] = array('ajax', '@WebProfiler/Collector/ajax.html.twig');
|
||||||
|
|
||||||
|
return $templates;
|
||||||
|
});
|
||||||
|
|
||||||
|
$app['data_collectors'] = $app->extend('data_collectors', function ($collectors) {
|
||||||
|
$collectors['ajax'] = function () {
|
||||||
|
return new AjaxDataCollector();
|
||||||
|
};
|
||||||
|
|
||||||
|
return $collectors;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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).
|
||||||
|
*/
|
||||||
|
public function boot(Application $app)
|
||||||
|
{
|
||||||
|
// TODO: Implement boot() method.
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user