Skip to content

Commit c20716a

Browse files
committed
[JsonEncoder] Fix retrieving encodable classes
1 parent 63ae307 commit c20716a

File tree

7 files changed

+6
-31
lines changed

7 files changed

+6
-31
lines changed

DependencyInjection/Configuration.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,16 +2580,6 @@ private function addJsonEncoderSection(ArrayNodeDefinition $rootNode, callable $
25802580
->arrayNode('json_encoder')
25812581
->info('JSON encoder configuration')
25822582
->{$enableIfStandalone('symfony/json-encoder', EncoderInterface::class)}()
2583-
->fixXmlConfig('path')
2584-
->children()
2585-
->arrayNode('paths')
2586-
->info('Namespaces and paths of encodable/decodable classes.')
2587-
->normalizeKeys(false)
2588-
->useAttributeAsKey('namespace')
2589-
->scalarPrototype()->end()
2590-
->defaultValue([])
2591-
->end()
2592-
->end()
25932583
->end()
25942584
->end()
25952585
;

DependencyInjection/FrameworkExtension.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,15 +2026,6 @@ private function registerJsonEncoderConfiguration(array $config, ContainerBuilde
20262026
$container->setParameter('.json_encoder.decoders_dir', '%kernel.cache_dir%/json_encoder/decoder');
20272027
$container->setParameter('.json_encoder.lazy_ghosts_dir', '%kernel.cache_dir%/json_encoder/lazy_ghost');
20282028

2029-
$encodableDefinition = (new Definition())
2030-
->setAbstract(true)
2031-
->addTag('container.excluded')
2032-
->addTag('json_encoder.encodable');
2033-
2034-
foreach ($config['paths'] as $namespace => $path) {
2035-
$loader->registerClasses($encodableDefinition, $namespace, $path);
2036-
}
2037-
20382029
if (\PHP_VERSION_ID >= 80400) {
20392030
$container->removeDefinition('.json_encoder.cache_warmer.lazy_ghost');
20402031
}

FrameworkBundle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
use Symfony\Component\HttpKernel\DependencyInjection\RemoveEmptyControllerArgumentLocatorsPass;
5555
use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass;
5656
use Symfony\Component\HttpKernel\KernelEvents;
57+
use Symfony\Component\JsonEncoder\DependencyInjection\EncodablePass;
5758
use Symfony\Component\Messenger\DependencyInjection\MessengerPass;
5859
use Symfony\Component\Mime\DependencyInjection\AddMimeTypeGuesserPass;
5960
use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass;
@@ -186,6 +187,7 @@ public function build(ContainerBuilder $container): void
186187
$container->addCompilerPass(new ErrorLoggerCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32);
187188
$container->addCompilerPass(new VirtualRequestStackPass());
188189
$container->addCompilerPass(new TranslationUpdateCommandPass(), PassConfig::TYPE_BEFORE_REMOVING);
190+
$container->addCompilerPass(new EncodablePass());
189191

190192
if ($container->getParameter('kernel.debug')) {
191193
$container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 2);

Resources/config/json_encoder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
// cache
108108
->set('.json_encoder.cache_warmer.encoder_decoder', EncoderDecoderCacheWarmer::class)
109109
->args([
110-
tagged_iterator('json_encoder.encodable'),
110+
abstract_arg('encodable class names'),
111111
service('json_encoder.encode.property_metadata_loader'),
112112
service('json_encoder.decode.property_metadata_loader'),
113113
param('.json_encoder.encoders_dir'),
@@ -118,7 +118,7 @@
118118

119119
->set('.json_encoder.cache_warmer.lazy_ghost', LazyGhostCacheWarmer::class)
120120
->args([
121-
tagged_iterator('json_encoder.encodable'),
121+
abstract_arg('encodable class names'),
122122
param('.json_encoder.lazy_ghosts_dir'),
123123
])
124124
->tag('kernel.cache_warmer')

Resources/config/schema/symfony-1.0.xsd

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,11 +1006,7 @@
10061006
</xsd:complexType>
10071007

10081008
<xsd:complexType name="json-encoder">
1009-
<xsd:choice minOccurs="0" maxOccurs="unbounded">
1010-
<xsd:sequence>
1011-
<xsd:element name="default-context" type="metadata" minOccurs="0" maxOccurs="1" />
1012-
</xsd:sequence>
1013-
</xsd:choice>
10141009
<xsd:attribute name="enabled" type="xsd:boolean" />
10151010
</xsd:complexType>
1011+
10161012
</xsd:schema>

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,6 @@ class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphor
973973
],
974974
'json_encoder' => [
975975
'enabled' => !class_exists(FullStack::class) && class_exists(JsonEncoder::class),
976-
'paths' => [],
977976
],
978977
];
979978
}

Tests/Functional/app/JsonEncoder/config.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ imports:
44
framework:
55
http_method_override: false
66
type_info: ~
7-
json_encoder:
8-
enabled: true
9-
paths:
10-
Symfony\Bundle\FrameworkBundle\Tests\Functional\app\JsonEncoder\Dto\: '../../Tests/Functional/app/JsonEncoder/Dto/*'
7+
json_encoder: ~
118

129
services:
1310
_defaults:

0 commit comments

Comments
 (0)