Skip to content

Commit

Permalink
#306. set public of 'translate' alias for compatibility with other c…
Browse files Browse the repository at this point in the history
…omponents in SF4. (#309)
  • Loading branch information
eugenekurasov authored and Gilles Gauthier committed Mar 12, 2018
1 parent 898b4cc commit 09dd52b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
6 changes: 5 additions & 1 deletion DependencyInjection/LexikTranslationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,11 @@ protected function buildDevServicesDefinition(ContainerBuilder $container)
protected function registerTranslatorConfiguration(array $config, ContainerBuilder $container)
{
// use the Lexik translator as default translator service
$container->setAlias('translator', 'lexik_translation.translator');
$alias = $container->setAlias('translator', 'lexik_translation.translator');

if (Kernel::VERSION_ID >= 30400) {
$alias->setPublic(true);
}

$translator = $container->findDefinition('lexik_translation.translator');
$translator->addMethodCall('setFallbackLocales', array($config['fallback_locale']));
Expand Down
11 changes: 9 additions & 2 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<parameter key="lexik_translation.token_finder.class">Lexik\Bundle\TranslationBundle\Util\Profiler\TokenFinder</parameter>

<parameter key="lexik_translation.command.import_translations.class">Lexik\Bundle\TranslationBundle\Command\ImportTranslationsCommand</parameter>
<parameter key="lexik_translation.command.export_translations.class">Lexik\Bundle\TranslationBundle\Command\ExportTranslationsCommand</parameter>

<parameter key="lexik_translation.importer.case_insensitive">false</parameter>
<parameter key="lexik_translation.token_finder.limit">15</parameter>
Expand Down Expand Up @@ -152,10 +153,16 @@
<tag name="kernel.event_listener" event="lexik_translation.event.get_database_resources" method="onGetDatabaseResources" />
</service>


<!-- Command -->
<service id="Lexik\Bundle\TranslationBundle\Command\ImportTranslationsCommand" class="%lexik_translation.command.import_translations.class%" autowire="true">
<argument type="service" id="lexik_translation.translator" />
<service id="Lexik\Bundle\TranslationBundle\Command\ImportTranslationsCommand" class="%lexik_translation.command.import_translations.class%">
<argument type="service" id="translator" />
<tag name="console.command" />
</service>

<service id="Lexik\Bundle\TranslationBundle\Command\ImportTranslationsCommand" class="%lexik_translation.command.export_translations.class%">
<tag name="console.command" />
</service>

</services>
</container>
2 changes: 1 addition & 1 deletion Tests/Command/ImportTranslationsCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private static function runCommand($commandName, $options = array())
*/
public function testExecute()
{
static::$application->add(new ImportTranslationsCommand(self::$kernel->getContainer()->get('lexik_translation.translator')));
static::$application->add(new ImportTranslationsCommand(self::$kernel->getContainer()->get('translator')));

$command = static::$application->find("lexik:translations:import");
$command->setContainer(static::$kernel->getContainer());
Expand Down

0 comments on commit 09dd52b

Please sign in to comment.