Skip to content
This repository was archived by the owner on Sep 14, 2018. It is now read-only.

Commit 690937a

Browse files
committed
feature #98 Added support for Translator debug section (iGusev)
This PR was squashed before being merged into the 2.0.x-dev branch (closes #98). Discussion ---------- Added support for Translator debug section Commits ------- dbfb219 Added support for Translator debug section
2 parents e0fff6f + dbfb219 commit 690937a

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

WebProfilerServiceProvider.php

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator;
5252
use Symfony\Component\Security\Core\Role\RoleHierarchy;
5353
use Symfony\Component\Stopwatch\Stopwatch;
54+
use Symfony\Component\Translation\DataCollector\TranslationDataCollector;
55+
use Symfony\Component\Translation\DataCollectorTranslator;
5456
use Symfony\Component\Yaml\Yaml;
5557

5658
/**
@@ -69,15 +71,16 @@ public function register(Container $app)
6971

7072
$app['data_collector.templates'] = function ($app) {
7173
$templates = array(
72-
array('config', '@WebProfiler/Collector/config.html.twig'),
73-
array('request', '@WebProfiler/Collector/request.html.twig'),
74-
array('exception', '@WebProfiler/Collector/exception.html.twig'),
75-
array('events', '@WebProfiler/Collector/events.html.twig'),
76-
array('logger', '@WebProfiler/Collector/logger.html.twig'),
77-
array('time', '@WebProfiler/Collector/time.html.twig'),
78-
array('router', '@WebProfiler/Collector/router.html.twig'),
79-
array('memory', '@WebProfiler/Collector/memory.html.twig'),
80-
array('form', '@WebProfiler/Collector/form.html.twig'),
74+
array('config', '@WebProfiler/Collector/config.html.twig'),
75+
array('request', '@WebProfiler/Collector/request.html.twig'),
76+
array('exception', '@WebProfiler/Collector/exception.html.twig'),
77+
array('events', '@WebProfiler/Collector/events.html.twig'),
78+
array('logger', '@WebProfiler/Collector/logger.html.twig'),
79+
array('time', '@WebProfiler/Collector/time.html.twig'),
80+
array('router', '@WebProfiler/Collector/router.html.twig'),
81+
array('memory', '@WebProfiler/Collector/memory.html.twig'),
82+
array('form', '@WebProfiler/Collector/form.html.twig'),
83+
array('translation', '@WebProfiler/Collector/translation.html.twig'),
8184
);
8285

8386
if (class_exists('Symfony\Bridge\Twig\Extension\ProfilerExtension')) {
@@ -183,7 +186,7 @@ public function register(Container $app)
183186
});
184187

185188
$app->extend('data_collector.templates', function ($templates) {
186-
$templates[] = ['security', '@Security/Collector/security.html.twig'];
189+
$templates[] = array('security', '@Security/Collector/security.html.twig');
187190

188191
return $templates;
189192
});
@@ -202,7 +205,7 @@ public function register(Container $app)
202205
return dirname(dirname($r->getFileName())).'/Resources/views';
203206
};
204207

205-
$app['twig'] = $app->extend('twig', function($twig, $app) {
208+
$app['twig'] = $app->extend('twig', function ($twig, $app) {
206209
$twig->addFilter('yaml_encode', new \Twig_SimpleFilter('yaml_encode', function (array $var) {
207210
return Yaml::dump($var);
208211
}));
@@ -215,6 +218,20 @@ public function register(Container $app)
215218
});
216219
}
217220

221+
if (isset($app['translator']) && class_exists('Symfony\Component\Translation\DataCollector\TranslationDataCollector')) {
222+
$app['data_collectors'] = $app->extend('data_collectors', function ($collectors, $app) {
223+
$collectors['translation'] = function ($app) {
224+
return new TranslationDataCollector($app['translator']);
225+
};
226+
227+
return $collectors;
228+
});
229+
230+
$app->extend('translator', function ($translator, $app) {
231+
return new DataCollectorTranslator($translator);
232+
});
233+
}
234+
218235
$app['web_profiler.controller.profiler'] = function ($app) {
219236
return new ProfilerController($app['url_generator'], $app['profiler'], $app['twig'], $app['data_collector.templates'], $app['web_profiler.debug_toolbar.position']);
220237
};

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"symfony/css-selector": "^2.8|^3.0",
2424
"symfony/debug-bundle": "^2.8|^3.0",
2525
"symfony/security": "^2.8|^3.0",
26-
"symfony/security-bundle": "^2.8|^3.0"
26+
"symfony/security-bundle": "^2.8|^3.0",
27+
"symfony/translation": "^2.8|^3.0"
2728
},
2829
"autoload": {
2930
"psr-0": { "Silex\\Provider\\": "" }

0 commit comments

Comments
 (0)