5151use Symfony \Component \Security \Http \Logout \LogoutUrlGenerator ;
5252use Symfony \Component \Security \Core \Role \RoleHierarchy ;
5353use Symfony \Component \Stopwatch \Stopwatch ;
54+ use Symfony \Component \Translation \DataCollector \TranslationDataCollector ;
55+ use Symfony \Component \Translation \DataCollectorTranslator ;
5456use 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 };
0 commit comments