Skip to content

Commit fc41289

Browse files
Merge branch '6.4' into 7.0
* 6.4: Partially revert "DX: PHP CS Fixer - update excluded paths and apply some minor CS" [AssetMapper] Allowing for files to be written to some non-local location [HttpKernel] Resolve EBADP error on flock with LOCK_SH with NFS [AssetMapper] Fixing bug of bad parsing of imports when an import then export are adjacent add missing basque translations [FrameworkBundle][Validator] Allow implementing validation groups provider outside DTOs [Notifier][Novu] Implement overrides [Validator] Handle `null` case [Workflow] List place or transition listeners in profiler [Intl] Add support for emoji 15.1 Replace Tickets by Issues [Validator] Add missing arabic translations [Validator] Added missing translations for Romanian language for Validator component [Messenger] Fix graceful exit with ids [HttpKernel] Add parameters `kernel.runtime_mode` and `kernel.runtime_mode.*`, all set from env var `APP_RUNTIME_MODE`
2 parents 779db9d + 9de16cf commit fc41289

File tree

8 files changed

+80
-54
lines changed

8 files changed

+80
-54
lines changed

DependencyInjection/Compiler/UnusedTagsPass.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class UnusedTagsPass implements CompilerPassInterface
9999
'twig.runtime',
100100
'validator.auto_mapper',
101101
'validator.constraint_validator',
102+
'validator.group_provider',
102103
'validator.initializer',
103104
'workflow',
104105
];

DependencyInjection/FrameworkExtension.php

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@
171171
use Symfony\Component\Uid\UuidV4;
172172
use Symfony\Component\Validator\Constraints\ExpressionLanguageProvider;
173173
use Symfony\Component\Validator\ConstraintValidatorInterface;
174+
use Symfony\Component\Validator\GroupProviderInterface;
174175
use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
175176
use Symfony\Component\Validator\ObjectInitializerInterface;
176177
use Symfony\Component\Validator\Validation;
@@ -636,6 +637,8 @@ public function load(array $configs, ContainerBuilder $container): void
636637
->addTag('serializer.normalizer');
637638
$container->registerForAutoconfiguration(ConstraintValidatorInterface::class)
638639
->addTag('validator.constraint_validator');
640+
$container->registerForAutoconfiguration(GroupProviderInterface::class)
641+
->addTag('validator.group_provider');
639642
$container->registerForAutoconfiguration(ObjectInitializerInterface::class)
640643
->addTag('validator.initializer');
641644
$container->registerForAutoconfiguration(BatchHandlerInterface::class)
@@ -1157,7 +1160,7 @@ private function registerDebugConfiguration(array $config, ContainerBuilder $con
11571160
$container->setDefinition('debug.log_processor', $definition);
11581161

11591162
$container->register('debug.debug_logger_configurator', DebugLoggerConfigurator::class)
1160-
->setArguments([new Reference('debug.log_processor')]);
1163+
->setArguments([new Reference('debug.log_processor'), '%kernel.runtime_mode.web%']);
11611164
}
11621165
}
11631166

@@ -1324,13 +1327,17 @@ private function registerAssetMapperConfiguration(array $config, ContainerBuilde
13241327
->setArgument(0, $paths)
13251328
->setArgument(2, $excludedPathPatterns);
13261329

1327-
$publicDirName = $this->getPublicDirectoryName($container);
13281330
$container->getDefinition('asset_mapper.public_assets_path_resolver')
1329-
->setArgument(1, $config['public_prefix'])
1330-
->setArgument(2, $publicDirName);
1331+
->setArgument(0, $config['public_prefix']);
13311332

1332-
$container->getDefinition('asset_mapper.command.compile')
1333-
->setArgument(5, $publicDirName);
1333+
$publicDirectory = $this->getPublicDirectory($container);
1334+
$publicAssetsDirectory = rtrim($publicDirectory.'/'.ltrim($config['public_prefix'], '/'), '/');
1335+
$container->getDefinition('asset_mapper.local_public_assets_filesystem')
1336+
->setArgument(0, $publicDirectory)
1337+
;
1338+
1339+
$container->getDefinition('asset_mapper.compiled_asset_mapper_config_reader')
1340+
->setArgument(0, $publicAssetsDirectory);
13341341

13351342
if (!$config['server']) {
13361343
$container->removeDefinition('asset_mapper.dev_server_subscriber');
@@ -3025,11 +3032,12 @@ private function writeConfigEnabled(string $path, bool $value, array &$config):
30253032
$config['enabled'] = $value;
30263033
}
30273034

3028-
private function getPublicDirectoryName(ContainerBuilder $container): string
3035+
private function getPublicDirectory(ContainerBuilder $container): string
30293036
{
3030-
$defaultPublicDir = 'public';
3037+
$projectDir = $container->getParameter('kernel.project_dir');
3038+
$defaultPublicDir = $projectDir.'/public';
30313039

3032-
$composerFilePath = $container->getParameter('kernel.project_dir').'/composer.json';
3040+
$composerFilePath = $projectDir.'/composer.json';
30333041

30343042
if (!file_exists($composerFilePath)) {
30353043
return $defaultPublicDir;
@@ -3038,6 +3046,6 @@ private function getPublicDirectoryName(ContainerBuilder $container): string
30383046
$container->addResource(new FileResource($composerFilePath));
30393047
$composerConfig = json_decode(file_get_contents($composerFilePath), true);
30403048

3041-
return $composerConfig['extra']['public-dir'] ?? $defaultPublicDir;
3049+
return isset($composerConfig['extra']['public-dir']) ? $projectDir.'/'.$composerConfig['extra']['public-dir'] : $defaultPublicDir;
30423050
}
30433051
}

Resources/config/asset_mapper.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Symfony\Component\AssetMapper\Command\ImportMapRemoveCommand;
2525
use Symfony\Component\AssetMapper\Command\ImportMapRequireCommand;
2626
use Symfony\Component\AssetMapper\Command\ImportMapUpdateCommand;
27+
use Symfony\Component\AssetMapper\CompiledAssetMapperConfigReader;
2728
use Symfony\Component\AssetMapper\Compiler\CssAssetUrlCompiler;
2829
use Symfony\Component\AssetMapper\Compiler\JavaScriptImportPathCompiler;
2930
use Symfony\Component\AssetMapper\Compiler\SourceMappingUrlsCompiler;
@@ -40,6 +41,7 @@
4041
use Symfony\Component\AssetMapper\ImportMap\RemotePackageStorage;
4142
use Symfony\Component\AssetMapper\ImportMap\Resolver\JsDelivrEsmResolver;
4243
use Symfony\Component\AssetMapper\MapperAwareAssetPackage;
44+
use Symfony\Component\AssetMapper\Path\LocalPublicAssetsFilesystem;
4345
use Symfony\Component\AssetMapper\Path\PublicAssetsPathResolver;
4446

4547
return static function (ContainerConfigurator $container) {
@@ -48,7 +50,7 @@
4850
->args([
4951
service('asset_mapper.repository'),
5052
service('asset_mapper.mapped_asset_factory'),
51-
service('asset_mapper.public_assets_path_resolver'),
53+
service('asset_mapper.compiled_asset_mapper_config_reader'),
5254
])
5355
->alias(AssetMapperInterface::class, 'asset_mapper')
5456

@@ -76,9 +78,17 @@
7678

7779
->set('asset_mapper.public_assets_path_resolver', PublicAssetsPathResolver::class)
7880
->args([
79-
param('kernel.project_dir'),
8081
abstract_arg('asset public prefix'),
81-
abstract_arg('public directory name'),
82+
])
83+
84+
->set('asset_mapper.local_public_assets_filesystem', LocalPublicAssetsFilesystem::class)
85+
->args([
86+
abstract_arg('public directory'),
87+
])
88+
89+
->set('asset_mapper.compiled_asset_mapper_config_reader', CompiledAssetMapperConfigReader::class)
90+
->args([
91+
abstract_arg('public assets directory'),
8292
])
8393

8494
->set('asset_mapper.asset_package', MapperAwareAssetPackage::class)
@@ -100,12 +110,11 @@
100110

101111
->set('asset_mapper.command.compile', AssetMapperCompileCommand::class)
102112
->args([
103-
service('asset_mapper.public_assets_path_resolver'),
113+
service('asset_mapper.compiled_asset_mapper_config_reader'),
104114
service('asset_mapper'),
105115
service('asset_mapper.importmap.generator'),
106-
service('filesystem'),
116+
service('asset_mapper.local_public_assets_filesystem'),
107117
param('kernel.project_dir'),
108-
abstract_arg('public directory name'),
109118
param('kernel.debug'),
110119
service('event_dispatcher')->nullOnInvalid(),
111120
])
@@ -163,7 +172,7 @@
163172
->set('asset_mapper.importmap.generator', ImportMapGenerator::class)
164173
->args([
165174
service('asset_mapper'),
166-
service('asset_mapper.public_assets_path_resolver'),
175+
service('asset_mapper.compiled_asset_mapper_config_reader'),
167176
service('asset_mapper.importmap.config_reader'),
168177
])
169178

Resources/config/debug_prod.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
->tag('monolog.logger', ['channel' => 'php'])
3333

3434
->set('debug.debug_handlers_listener', DebugHandlersListener::class)
35+
->args([null, param('kernel.runtime_mode.web')])
3536
->tag('kernel.event_subscriber')
3637

3738
->set('debug.file_link_formatter', FileLinkFormatter::class)

Resources/config/validator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
->call('setConstraintValidatorFactory', [
4343
service('validator.validator_factory'),
4444
])
45+
->call('setGroupProviderLocator', [
46+
tagged_locator('validator.group_provider'),
47+
])
4548
->call('setTranslator', [
4649
service('translator')->ignoreOnInvalid(),
4750
])

Resources/config/workflow_debug.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
])
2323
->args([
2424
tagged_iterator('workflow', 'name'),
25+
service('event_dispatcher'),
26+
service('debug.file_link_formatter'),
2527
])
2628
;
2729
};

Tests/DependencyInjection/FrameworkExtensionTestCase.php

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,16 +1193,18 @@ public function testValidation()
11931193

11941194
$annotations = !class_exists(FullStack::class);
11951195

1196-
$this->assertCount($annotations ? 7 : 6, $calls);
1196+
$this->assertCount($annotations ? 8 : 7, $calls);
11971197
$this->assertSame('setConstraintValidatorFactory', $calls[0][0]);
11981198
$this->assertEquals([new Reference('validator.validator_factory')], $calls[0][1]);
1199-
$this->assertSame('setTranslator', $calls[1][0]);
1200-
$this->assertEquals([new Reference('translator', ContainerBuilder::IGNORE_ON_INVALID_REFERENCE)], $calls[1][1]);
1201-
$this->assertSame('setTranslationDomain', $calls[2][0]);
1202-
$this->assertSame(['%validator.translation_domain%'], $calls[2][1]);
1203-
$this->assertSame('addXmlMappings', $calls[3][0]);
1204-
$this->assertSame([$xmlMappings], $calls[3][1]);
1205-
$i = 3;
1199+
$this->assertSame('setGroupProviderLocator', $calls[1][0]);
1200+
$this->assertInstanceOf(ServiceLocatorArgument::class, $calls[1][1][0]);
1201+
$this->assertSame('setTranslator', $calls[2][0]);
1202+
$this->assertEquals([new Reference('translator', ContainerBuilder::IGNORE_ON_INVALID_REFERENCE)], $calls[2][1]);
1203+
$this->assertSame('setTranslationDomain', $calls[3][0]);
1204+
$this->assertSame(['%validator.translation_domain%'], $calls[3][1]);
1205+
$this->assertSame('addXmlMappings', $calls[4][0]);
1206+
$this->assertSame([$xmlMappings], $calls[4][1]);
1207+
$i = 4;
12061208
if ($annotations) {
12071209
$this->assertSame('enableAttributeMapping', $calls[++$i][0]);
12081210
}
@@ -1248,12 +1250,12 @@ public function testValidationAttributes()
12481250

12491251
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
12501252

1251-
$this->assertCount(7, $calls);
1252-
$this->assertSame('enableAttributeMapping', $calls[4][0]);
1253-
$this->assertSame('addMethodMapping', $calls[5][0]);
1254-
$this->assertSame(['loadValidatorMetadata'], $calls[5][1]);
1255-
$this->assertSame('setMappingCache', $calls[6][0]);
1256-
$this->assertEquals([new Reference('validator.mapping.cache.adapter')], $calls[6][1]);
1253+
$this->assertCount(8, $calls);
1254+
$this->assertSame('enableAttributeMapping', $calls[5][0]);
1255+
$this->assertSame('addMethodMapping', $calls[6][0]);
1256+
$this->assertSame(['loadValidatorMetadata'], $calls[6][1]);
1257+
$this->assertSame('setMappingCache', $calls[7][0]);
1258+
$this->assertEquals([new Reference('validator.mapping.cache.adapter')], $calls[7][1]);
12571259
// no cache this time
12581260
}
12591261

@@ -1268,16 +1270,16 @@ public function testValidationPaths()
12681270

12691271
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
12701272

1271-
$this->assertCount(8, $calls);
1272-
$this->assertSame('addXmlMappings', $calls[3][0]);
1273-
$this->assertSame('addYamlMappings', $calls[4][0]);
1274-
$this->assertSame('enableAttributeMapping', $calls[5][0]);
1275-
$this->assertSame('addMethodMapping', $calls[6][0]);
1276-
$this->assertSame(['loadValidatorMetadata'], $calls[6][1]);
1277-
$this->assertSame('setMappingCache', $calls[7][0]);
1278-
$this->assertEquals([new Reference('validator.mapping.cache.adapter')], $calls[7][1]);
1273+
$this->assertCount(9, $calls);
1274+
$this->assertSame('addXmlMappings', $calls[4][0]);
1275+
$this->assertSame('addYamlMappings', $calls[5][0]);
1276+
$this->assertSame('enableAttributeMapping', $calls[6][0]);
1277+
$this->assertSame('addMethodMapping', $calls[7][0]);
1278+
$this->assertSame(['loadValidatorMetadata'], $calls[7][1]);
1279+
$this->assertSame('setMappingCache', $calls[8][0]);
1280+
$this->assertEquals([new Reference('validator.mapping.cache.adapter')], $calls[8][1]);
12791281

1280-
$xmlMappings = $calls[3][1][0];
1282+
$xmlMappings = $calls[4][1][0];
12811283
$this->assertCount(3, $xmlMappings);
12821284
try {
12831285
// Testing symfony/symfony
@@ -1288,7 +1290,7 @@ public function testValidationPaths()
12881290
}
12891291
$this->assertStringEndsWith('TestBundle/Resources/config/validation.xml', $xmlMappings[1]);
12901292

1291-
$yamlMappings = $calls[4][1][0];
1293+
$yamlMappings = $calls[5][1][0];
12921294
$this->assertCount(1, $yamlMappings);
12931295
$this->assertStringEndsWith('TestBundle/Resources/config/validation.yml', $yamlMappings[0]);
12941296
}
@@ -1303,7 +1305,7 @@ public function testValidationPathsUsingCustomBundlePath()
13031305
]);
13041306

13051307
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
1306-
$xmlMappings = $calls[3][1][0];
1308+
$xmlMappings = $calls[4][1][0];
13071309
$this->assertCount(3, $xmlMappings);
13081310

13091311
try {
@@ -1315,7 +1317,7 @@ public function testValidationPathsUsingCustomBundlePath()
13151317
}
13161318
$this->assertStringEndsWith('CustomPathBundle/Resources/config/validation.xml', $xmlMappings[1]);
13171319

1318-
$yamlMappings = $calls[4][1][0];
1320+
$yamlMappings = $calls[5][1][0];
13191321
$this->assertCount(1, $yamlMappings);
13201322
$this->assertStringEndsWith('CustomPathBundle/Resources/config/validation.yml', $yamlMappings[0]);
13211323
}
@@ -1328,9 +1330,9 @@ public function testValidationNoStaticMethod()
13281330

13291331
$annotations = !class_exists(FullStack::class);
13301332

1331-
$this->assertCount($annotations ? 6 : 5, $calls);
1332-
$this->assertSame('addXmlMappings', $calls[3][0]);
1333-
$i = 3;
1333+
$this->assertCount($annotations ? 7 : 6, $calls);
1334+
$this->assertSame('addXmlMappings', $calls[4][0]);
1335+
$i = 4;
13341336
if ($annotations) {
13351337
$this->assertSame('enableAttributeMapping', $calls[++$i][0]);
13361338
}
@@ -1359,14 +1361,14 @@ public function testValidationMapping()
13591361

13601362
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
13611363

1362-
$this->assertSame('addXmlMappings', $calls[3][0]);
1363-
$this->assertCount(3, $calls[3][1][0]);
1364-
1365-
$this->assertSame('addYamlMappings', $calls[4][0]);
1364+
$this->assertSame('addXmlMappings', $calls[4][0]);
13661365
$this->assertCount(3, $calls[4][1][0]);
1367-
$this->assertStringContainsString('foo.yml', $calls[4][1][0][0]);
1368-
$this->assertStringContainsString('validation.yml', $calls[4][1][0][1]);
1369-
$this->assertStringContainsString('validation.yaml', $calls[4][1][0][2]);
1366+
1367+
$this->assertSame('addYamlMappings', $calls[5][0]);
1368+
$this->assertCount(3, $calls[5][1][0]);
1369+
$this->assertStringContainsString('foo.yml', $calls[5][1][0][0]);
1370+
$this->assertStringContainsString('validation.yml', $calls[5][1][0][1]);
1371+
$this->assertStringContainsString('validation.yaml', $calls[5][1][0][2]);
13701372
}
13711373

13721374
public function testValidationAutoMapping()

Tests/DependencyInjection/XmlFrameworkExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testAssetMapper()
4545
$container = $this->createContainerFromFile('asset_mapper');
4646

4747
$definition = $container->getDefinition('asset_mapper.public_assets_path_resolver');
48-
$this->assertSame('/assets_path/', $definition->getArgument(1));
48+
$this->assertSame('/assets_path/', $definition->getArgument(0));
4949

5050
$definition = $container->getDefinition('asset_mapper.dev_server_subscriber');
5151
$this->assertSame(['zip' => 'application/zip'], $definition->getArgument(2));

0 commit comments

Comments
 (0)