Skip to content

Commit e5eebb6

Browse files
Merge branch '7.4' into 8.0
* 7.4: [Translation] Make the extractor alias optional [Cache] Fix accepting named closures as early-expiration callbacks [Mime] Update mime types [HttpKernel] Conflict with symfony/flex < 2.10 [Yaml] Align unquoted multiline scalar parsing with spec for comments work around limitation in JsonResponse when the data is null do not use recipient phone numbers as sender e-mail addresses [Dotenv] DotenvDumpCommand cannot be internal
2 parents dd45a1c + e64bc06 commit e5eebb6

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ CHANGELOG
1212
7.4
1313
---
1414

15+
* Make the extractor alias optional
1516
* Deprecate `TranslatableMessage::__toString`
1617
* Add `Symfony\Component\Translation\StaticMessage`
1718

DependencyInjection/TranslationExtractorPass.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
16-
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
1716
use Symfony\Component\DependencyInjection\Reference;
1817

1918
/**
@@ -30,11 +29,7 @@ public function process(ContainerBuilder $container): void
3029
$definition = $container->getDefinition('translation.extractor');
3130

3231
foreach ($container->findTaggedServiceIds('translation.extractor', true) as $id => $attributes) {
33-
if (!isset($attributes[0]['alias'])) {
34-
throw new RuntimeException(\sprintf('The alias for the tag "translation.extractor" of service "%s" must be set.', $id));
35-
}
36-
37-
$definition->addMethodCall('addExtractor', [$attributes[0]['alias'], new Reference($id)]);
32+
$definition->addMethodCall('addExtractor', [$attributes[0]['alias'] ?? $id, new Reference($id)]);
3833
}
3934
}
4035
}

Tests/DependencyInjection/TranslationExtractorPassTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
16-
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
1716
use Symfony\Component\DependencyInjection\Reference;
1817
use Symfony\Component\Translation\DependencyInjection\TranslationExtractorPass;
1918

@@ -50,15 +49,13 @@ public function testProcessNoDefinitionFound()
5049
public function testProcessMissingAlias()
5150
{
5251
$container = new ContainerBuilder();
53-
$container->register('translation.extractor');
52+
$extractorDefinition = $container->register('translation.extractor');
5453
$container->register('foo.id')
5554
->addTag('translation.extractor', []);
5655

5756
$translationDumperPass = new TranslationExtractorPass();
58-
59-
$this->expectException(RuntimeException::class);
60-
$this->expectExceptionMessage('The alias for the tag "translation.extractor" of service "foo.id" must be set.');
61-
6257
$translationDumperPass->process($container);
58+
59+
$this->assertEquals([['addExtractor', ['foo.id', new Reference('foo.id')]]], $extractorDefinition->getMethodCalls());
6360
}
6461
}

0 commit comments

Comments
 (0)