Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 20bb3cb

Browse files
Merge branch '5.2' into 5.x
* 5.2: merge translation parameters with value configured for parent form scan directories for translations sequentially Fix kafka tests Fix "provide" declarations Provide implemented packages of replaced dependencies Always autoload string functions on symfony/symfony
2 parents 6e513fe + 7866a0f commit 20bb3cb

File tree

12 files changed

+98
-25
lines changed

12 files changed

+98
-25
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
env:
9090
KAFKA_AUTO_CREATE_TOPICS_ENABLE: false
9191
KAFKA_CREATE_TOPICS: 'test-topic:1:1:compact'
92-
KAFKA_ADVERTISED_HOST_NAME: localhost
92+
KAFKA_ADVERTISED_HOST_NAME: 127.0.0.1
9393
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
9494
KAFKA_ADVERTISED_PORT: 9092
9595

@@ -177,7 +177,7 @@ jobs:
177177
LDAP_HOST: localhost
178178
LDAP_PORT: 3389
179179
MONGODB_HOST: localhost
180-
KAFKA_BROKER: localhost:9092
180+
KAFKA_BROKER: 127.0.0.1:9092
181181
POSTGRES_HOST: localhost
182182

183183
- name: Run HTTP push tests

composer.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@
1515
"homepage": "https://symfony.com/contributors"
1616
}
1717
],
18+
"provide": {
19+
"php-http/async-client-implementation": "*",
20+
"php-http/client-implementation": "*",
21+
"psr/cache-implementation": "1.0|2.0",
22+
"psr/container-implementation": "1.0",
23+
"psr/event-dispatcher-implementation": "1.0",
24+
"psr/http-client-implementation": "1.0",
25+
"psr/link-implementation": "1.0",
26+
"psr/log-implementation": "1.0",
27+
"psr/simple-cache-implementation": "1.0",
28+
"symfony/cache-implementation": "1.0|2.0",
29+
"symfony/event-dispatcher-implementation": "2.0",
30+
"symfony/http-client-implementation": "2.2",
31+
"symfony/service-implementation": "1.0|2.0",
32+
"symfony/translation-implementation": "2.3"
33+
},
1834
"require": {
1935
"php": ">=7.2.5",
2036
"ext-xml": "*",
@@ -150,6 +166,9 @@
150166
"Symfony\\Bundle\\": "src/Symfony/Bundle/",
151167
"Symfony\\Component\\": "src/Symfony/Component/"
152168
},
169+
"files": [
170+
"src/Symfony/Component/String/Resources/functions.php"
171+
],
153172
"classmap": [
154173
"src/Symfony/Component/Intl/Resources/stubs"
155174
],
@@ -159,7 +178,6 @@
159178
},
160179
"autoload-dev": {
161180
"files": [
162-
"src/Symfony/Component/String/Resources/functions.php",
163181
"src/Symfony/Component/VarDumper/Resources/functions/dump.php"
164182
]
165183
},

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,24 +1228,26 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
12281228
// Register translation resources
12291229
if ($dirs) {
12301230
$files = [];
1231-
$finder = Finder::create()
1232-
->followLinks()
1233-
->files()
1234-
->filter(function (\SplFileInfo $file) {
1235-
return 2 <= substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/', $file->getBasename());
1236-
})
1237-
->in($dirs)
1238-
->sortByName()
1239-
;
12401231

1241-
foreach ($finder as $file) {
1242-
$fileNameParts = explode('.', basename($file));
1243-
$locale = $fileNameParts[\count($fileNameParts) - 2];
1244-
if (!isset($files[$locale])) {
1245-
$files[$locale] = [];
1246-
}
1232+
foreach ($dirs as $dir) {
1233+
$finder = Finder::create()
1234+
->followLinks()
1235+
->files()
1236+
->filter(function (\SplFileInfo $file) {
1237+
return 2 <= substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/', $file->getBasename());
1238+
})
1239+
->in($dir)
1240+
->sortByName()
1241+
;
1242+
foreach ($finder as $file) {
1243+
$fileNameParts = explode('.', basename($file));
1244+
$locale = $fileNameParts[\count($fileNameParts) - 2];
1245+
if (!isset($files[$locale])) {
1246+
$files[$locale] = [];
1247+
}
12471248

1248-
$files[$locale][] = (string) $file;
1249+
$files[$locale][] = (string) $file;
1250+
}
12491251
}
12501252

12511253
$projectDir = $container->getParameter('kernel.project_dir');

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,19 @@ public function testTranslator()
859859
$files,
860860
'->registerTranslatorConfiguration() finds translation resources with dots in domain'
861861
);
862+
$this->assertContains(strtr(__DIR__.'/translations/security.en.yaml', '/', \DIRECTORY_SEPARATOR), $files);
863+
864+
$positionOverridingTranslationFile = array_search(strtr(realpath(__DIR__.'/translations/security.en.yaml'), '/', \DIRECTORY_SEPARATOR), $files);
865+
866+
if (false !== $positionCoreTranslationFile = array_search(strtr(realpath(__DIR__.'/../../../../Component/Security/Core/Resources/translations/security.en.xlf'), '/', \DIRECTORY_SEPARATOR), $files)) {
867+
$this->assertContains(strtr(realpath(__DIR__.'/../../../../Component/Security/Core/Resources/translations/security.en.xlf'), '/', \DIRECTORY_SEPARATOR), $files);
868+
} else {
869+
$this->assertContains(strtr(realpath(__DIR__.'/../../vendor/symfony/security-core/Resources/translations/security.en.xlf'), '/', \DIRECTORY_SEPARATOR), $files);
870+
871+
$positionCoreTranslationFile = array_search(strtr(realpath(__DIR__.'/../../vendor/symfony/security-core/Resources/translations/security.en.xlf'), '/', \DIRECTORY_SEPARATOR), $files);
872+
}
873+
874+
$this->assertGreaterThan($positionCoreTranslationFile, $positionOverridingTranslationFile);
862875

863876
$calls = $container->getDefinition('translator.default')->getMethodCalls();
864877
$this->assertEquals(['fr'], $calls[1][1][0]);

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/translations/security.en.yaml

Whitespace-only changes.

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"symfony/messenger": "^5.2",
5252
"symfony/mime": "^4.4|^5.0",
5353
"symfony/process": "^4.4|^5.0",
54-
"symfony/security-bundle": "^5.1",
54+
"symfony/security-bundle": "^5.2",
5555
"symfony/serializer": "^5.2",
5656
"symfony/stopwatch": "^4.4|^5.0",
5757
"symfony/string": "^5.0",

src/Symfony/Component/Cache/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"provide": {
1919
"psr/cache-implementation": "1.0|2.0",
2020
"psr/simple-cache-implementation": "1.0",
21-
"symfony/cache-implementation": "1.0"
21+
"symfony/cache-implementation": "1.0|2.0"
2222
},
2323
"require": {
2424
"php": ">=7.2.5",

src/Symfony/Component/DependencyInjection/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
},
4343
"provide": {
4444
"psr/container-implementation": "1.0",
45-
"symfony/service-implementation": "1.0"
45+
"symfony/service-implementation": "1.0|2.0"
4646
},
4747
"autoload": {
4848
"psr-4": { "Symfony\\Component\\DependencyInjection\\": "" },

src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,16 @@ public function mapViolation(ConstraintViolation $violation, FormInterface $form
185185

186186
if (null !== $this->translator) {
187187
$form = $scope;
188+
$translationParameters = $form->getConfig()->getOption('label_translation_parameters', []);
188189

189190
do {
190191
$translationDomain = $form->getConfig()->getOption('translation_domain');
192+
$translationParameters = array_merge($form->getConfig()->getOption('label_translation_parameters', []), $translationParameters);
191193
} while (null === $translationDomain && null !== $form = $form->getParent());
192194

193195
$label = $this->translator->trans(
194196
$label,
195-
$scope->getConfig()->getOption('label_translation_parameters', []),
197+
$translationParameters,
196198
$translationDomain
197199
);
198200
}

src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,44 @@ public function testLabelPlaceholderTranslatedWithTranslationDomainDefinedByPare
17861786
$this->assertSame('Message "translated foo label"', $errors[0]->getMessage());
17871787
}
17881788

1789+
public function testLabelPlaceholderTranslatedWithTranslationParametersMergedFromParentForm()
1790+
{
1791+
$translator = $this->createMock(TranslatorInterface::class);
1792+
$translator->expects($this->any())
1793+
->method('trans')
1794+
->with('foo', [
1795+
'{{ param_defined_in_parent }}' => 'param defined in parent value',
1796+
'{{ param_defined_in_child }}' => 'param defined in child value',
1797+
'{{ param_defined_in_parent_overridden_in_child }}' => 'param defined in parent overridden in child child value',
1798+
])
1799+
->willReturn('translated foo label')
1800+
;
1801+
$this->mapper = new ViolationMapper(null, $translator);
1802+
1803+
$form = $this->getForm('', null, null, [], false, true, [
1804+
'label_translation_parameters' => [
1805+
'{{ param_defined_in_parent }}' => 'param defined in parent value',
1806+
'{{ param_defined_in_parent_overridden_in_child }}' => 'param defined in parent overridden in child parent value',
1807+
],
1808+
]);
1809+
$child = $this->getForm('foo', 'foo', null, [], false, true, [
1810+
'label' => 'foo',
1811+
'label_translation_parameters' => [
1812+
'{{ param_defined_in_child }}' => 'param defined in child value',
1813+
'{{ param_defined_in_parent_overridden_in_child }}' => 'param defined in parent overridden in child child value',
1814+
],
1815+
]);
1816+
$form->add($child);
1817+
1818+
$violation = new ConstraintViolation('Message "{{ label }}"', null, [], null, 'data.foo', null);
1819+
$this->mapper->mapViolation($violation, $form);
1820+
1821+
$errors = iterator_to_array($child->getErrors());
1822+
1823+
$this->assertCount(1, $errors, $child->getName().' should have an error, but has none');
1824+
$this->assertSame('Message "translated foo label"', $errors[0]->getMessage());
1825+
}
1826+
17891827
public function testTranslatorNotCalledWithoutLabel()
17901828
{
17911829
$renderer = $this->getMockBuilder(FormRenderer::class)

src/Symfony/Component/HttpClient/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"php-http/async-client-implementation": "*",
1919
"php-http/client-implementation": "*",
2020
"psr/http-client-implementation": "1.0",
21-
"symfony/http-client-implementation": "1.1"
21+
"symfony/http-client-implementation": "2.2"
2222
},
2323
"require": {
2424
"php": ">=7.2.5",

src/Symfony/Component/Translation/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"symfony/yaml": "<4.4"
4141
},
4242
"provide": {
43-
"symfony/translation-implementation": "2.0"
43+
"symfony/translation-implementation": "2.3"
4444
},
4545
"suggest": {
4646
"symfony/config": "",

0 commit comments

Comments
 (0)