Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use XliffLoader for format xlf instead of Symfony's loader #462

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions DependencyInjection/Compiler/MountLoadersPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ public function process(ContainerBuilder $container)
$loaders[$attr[0]['alias']] = new Reference($id);
}

foreach ($container->findTaggedServiceIds('jms_translation.loader') as $id => $attr) {
if (!isset($attr[0]['format'])) {
throw new RuntimeException(sprintf('The attribute "format" must be defined for tag "jms_translation.loader" for service "%s".', $id));
}
foreach ($container->findTaggedServiceIds('jms_translation.loader') as $id => $tags) {
foreach ($tags as $tag) {
if (!isset($tag['format'])) {
throw new RuntimeException(sprintf('The attribute "format" must be defined for tag "jms_translation.loader" for service "%s".', $id));
}

$loaders[$attr[0]['format']] = new Reference($id);
$loaders[$tag['format']] = new Reference($id);
}
}

$container
Expand Down
1 change: 1 addition & 0 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<service id="jms_translation.loader_manager" class="%jms_translation.loader_manager.class%" /><!-- public as needed by the TranslateController -->
<service id="jms_translation.loader.xliff_loader" class="%jms_translation.loader.xliff_loader.class%" public="false">
<tag name="jms_translation.loader" format="xliff" />
<tag name="jms_translation.loader" format="xlf" />
</service>

<!-- Dumpers -->
Expand Down
6 changes: 5 additions & 1 deletion Tests/DependencyInjection/Compiler/MountLoadersPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@ public function if_compiler_pass_collects_services_by_argument_these_will_exist(

$collectedService = new Definition();
$collectedService->addTag('jms_translation.loader', array('format' => 'foo'));
$collectedService->addTag('jms_translation.loader', array('format' => 'bar'));
$this->setDefinition('service0', $collectedService);

$this->compile();

$this->assertContainerBuilderHasServiceDefinitionWithArgument(
'jms_translation.loader_manager',
0,
array('foo' => new Reference('service0'))
array(
'foo' => new Reference('service0'),
'bar' => new Reference('service0'),
)
);
}
}