Allow API to be used with WebProfiler

This commit is contained in:
Benoît Burnichon
2015-05-26 18:35:57 +02:00
parent d77b55388d
commit c083cd5d53
2 changed files with 17 additions and 1 deletions

View File

@@ -28,6 +28,8 @@ use Alchemy\Phrasea\Core\Provider\JsonSchemaServiceProvider;
use Monolog\Logger; use Monolog\Logger;
use Monolog\Processor\WebProcessor; use Monolog\Processor\WebProcessor;
use Silex\Application as SilexApplication; use Silex\Application as SilexApplication;
use Silex\Provider\WebProfilerServiceProvider;
use Sorien\Provider\DoctrineProfilerServiceProvider;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@@ -125,6 +127,20 @@ return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) {
$app->mount($app['controller.media_accessor.route_prefix'], new MediaAccessor()); $app->mount($app['controller.media_accessor.route_prefix'], new MediaAccessor());
$app->mount('/include/minify/', new Minifier()); $app->mount('/include/minify/', new Minifier());
if (PhraseaApplication::ENV_DEV === $app->getEnvironment()) {
$app->register($p = new WebProfilerServiceProvider(), [
'profiler.cache_dir' => $app['cache.path'].'/profiler',
]);
$app->mount('/_profiler', $p);
if ($app['phraseanet.configuration-tester']->isInstalled()) {
$app->register(new DoctrineProfilerServiceProvider());
$app['db'] = $app->share(function (PhraseaApplication $app) {
return $app['orm.em']->getConnection();
});
}
}
$app['dispatcher'] = $app->share($app->extend('dispatcher', function ($dispatcher, PhraseaApplication $app) { $app['dispatcher'] = $app->share($app->extend('dispatcher', function ($dispatcher, PhraseaApplication $app) {
$dispatcher->addSubscriber(new ApiOauth2ErrorsSubscriber($app['phraseanet.exception_handler'], $app['translator'])); $dispatcher->addSubscriber(new ApiOauth2ErrorsSubscriber($app['phraseanet.exception_handler'], $app['translator']));

View File

@@ -18,7 +18,7 @@ error_reporting(0);
ErrorHandler::register(); ErrorHandler::register();
$environment = Application::ENV_PROD; $environment = getenv('APP_ENV') ?: Application::ENV_PROD;
$app = require __DIR__ . '/../lib/Alchemy/Phrasea/Application/Api.php'; $app = require __DIR__ . '/../lib/Alchemy/Phrasea/Application/Api.php';
$app->run(); $app->run();