|
31 | 31 | use ApiPlatform\GraphQl\Resolver\QueryItemResolverInterface; |
32 | 32 | use ApiPlatform\GraphQl\Type\Definition\TypeInterface as GraphQlTypeInterface; |
33 | 33 | use ApiPlatform\Metadata\ApiResource; |
| 34 | +use ApiPlatform\Metadata\AsResourceMutator; |
34 | 35 | use ApiPlatform\Metadata\FilterInterface; |
35 | 36 | use ApiPlatform\Metadata\UriVariableTransformerInterface; |
36 | 37 | use ApiPlatform\Metadata\UrlGeneratorInterface; |
@@ -184,6 +185,13 @@ public function load(array $configs, ContainerBuilder $container): void |
184 | 185 | ->addTag('api_platform.resource') |
185 | 186 | ->addTag('container.excluded', ['source' => 'by #[ApiResource] attribute']); |
186 | 187 | }); |
| 188 | + $container->registerAttributeForAutoconfiguration(AsResourceMutator::class, |
| 189 | + static function (ChildDefinition $definition, AsResourceMutator $attribute): void { |
| 190 | + $definition->addTag('api_platform.resource_mutator', [ |
| 191 | + 'resourceClass' => $attribute->resourceClass, |
| 192 | + ]); |
| 193 | + }, |
| 194 | + ); |
187 | 195 |
|
188 | 196 | if (!$container->has('api_platform.state.item_provider')) { |
189 | 197 | $container->setAlias('api_platform.state.item_provider', 'api_platform.state_provider.object'); |
@@ -341,6 +349,7 @@ private function registerMetadataConfiguration(ContainerBuilder $container, arra |
341 | 349 | $loader->load('metadata/property.xml'); |
342 | 350 | $loader->load('metadata/resource.xml'); |
343 | 351 | $loader->load('metadata/operation.xml'); |
| 352 | + $loader->load('metadata/mutator.xml'); |
344 | 353 |
|
345 | 354 | $container->getDefinition('api_platform.metadata.resource_extractor.xml')->replaceArgument(0, $xmlResources); |
346 | 355 | $container->getDefinition('api_platform.metadata.property_extractor.xml')->replaceArgument(0, $xmlResources); |
|
0 commit comments