Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[FrameworkBundle] don't load translator services if not required#20928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -14,6 +14,7 @@ | ||
| use Doctrine\Common\Annotations\Reader; | ||
| use Symfony\Bridge\Monolog\Processor\DebugProcessor; | ||
| use Symfony\Component\Cache\Adapter\AdapterInterface; | ||
| use Symfony\Component\Config\Loader\LoaderInterface; | ||
| use Symfony\Component\DependencyInjection\Alias; | ||
| use Symfony\Component\DependencyInjection\ChildDefinition; | ||
| use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
| @@ -85,14 +86,22 @@ public function load(array $configs, ContainerBuilder $container) | ||
| $this->annotationsConfigEnabled = $this->isConfigEnabled($container, $config['annotations']); | ||
| // A translator must always be registered (as support is included by | ||
| // default in the Form and Validator component). If disabled, an identity | ||
| // translator will be used and everything will still work as expected. | ||
| if ($this->isConfigEnabled($container, $config['translator']) || $this->isConfigEnabled($container, $config['form']) || $this->isConfigEnabled($container, $config['validation'])) { | ||
| if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['translator'])) { | ||
| throw new LogicException('Translation support cannot be enabled as the Translation component is not installed.'); | ||
| } | ||
| if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['form'])) { | ||
| throw new LogicException('Form support cannot be enabled as the Translation component is not installed.'); | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. The error message should probably be different for the first case. MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Indeed, updated it. | ||
| } | ||
| if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['validation'])) { | ||
| throw new LogicException('Validation support cannot be enabled as the Translation component is not installed.'); | ||
| } | ||
| $loader->load('identity_translator.xml'); | ||
| } | ||
| if (isset($config['secret'])) { | ||
| @@ -165,7 +174,7 @@ public function load(array $configs, ContainerBuilder $container) | ||
| $this->registerEsiConfiguration($config['esi'], $container, $loader); | ||
| $this->registerSsiConfiguration($config['ssi'], $container, $loader); | ||
| $this->registerFragmentsConfiguration($config['fragments'], $container, $loader); | ||
| $this->registerTranslatorConfiguration($config['translator'], $container, $loader); | ||
| $this->registerProfilerConfiguration($config['profiler'], $container, $loader); | ||
| $this->registerCacheConfiguration($config['cache'], $container); | ||
| $this->registerWorkflowConfiguration($config['workflows'], $container, $loader); | ||
| @@ -802,15 +811,13 @@ private function createVersion(ContainerBuilder $container, $version, $format, $ | ||
| * @param array $config A translator configuration array | ||
| * @param ContainerBuilder $container A ContainerBuilder instance | ||
| */ | ||
| private function registerTranslatorConfiguration(array $config, ContainerBuilder $container, LoaderInterface $loader) | ||
| { | ||
| if (!$this->isConfigEnabled($container, $config)) { | ||
| return; | ||
| } | ||
| $loader->load('translation.xml'); | ||
| $this->translationConfigEnabled = true; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <?xml version="1.0" ?> | ||
| <container xmlns="http://symfony.com/schema/dic/services" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
| <services> | ||
| <service id="translator" class="Symfony\Component\Translation\IdentityTranslator"> | ||
| <argument type="service" id="translator.selector" /> | ||
| </service> | ||
| <service id="translator.selector" class="Symfony\Component\Translation\MessageSelector" public="false" /> | ||
| </services> | ||
| </container> |