File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
src/Translator/src/DependencyInjection Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 6
6
7
7
use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
8
8
use Symfony \Component \DependencyInjection \ContainerBuilder ;
9
+ use Symfony \Component \Translation \TranslatorBagInterface ;
9
10
10
11
class TranslatorCompilerPass implements CompilerPassInterface
11
12
{
12
13
public function process (ContainerBuilder $ container )
13
14
{
14
- if (!$ container -> hasDefinition ( ' translator ' )) {
15
+ if (!$ this -> hasValidTranslator ( $ container )) {
15
16
$ container ->removeDefinition ('ux.translator.cache_warmer.translations_cache_warmer ' );
16
17
}
17
18
}
19
+
20
+ private function hasValidTranslator (ContainerBuilder $ containerBuilder ): bool
21
+ {
22
+ if (!$ containerBuilder ->hasDefinition ('translator ' )) {
23
+ return false ;
24
+ }
25
+
26
+ $ translator = $ containerBuilder ->getDefinition ('translator ' );
27
+ if (!is_subclass_of ($ translator ->getClass (), TranslatorBagInterface::class)) {
28
+ return false ;
29
+ }
30
+ return true ;
31
+ }
18
32
}
You can’t perform that action at this time.
0 commit comments