Skip to content

Commit 7bb70f6

Browse files
GregoireHebertsoyuka
authored andcommitted
Add autoconfiguration for tag 'api_platform.data_transformer'
update test
1 parent eac03c2 commit 7bb70f6

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use ApiPlatform\Core\DataProvider\CollectionDataProviderInterface;
2626
use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
2727
use ApiPlatform\Core\DataProvider\SubresourceDataProviderInterface;
28+
use ApiPlatform\Core\DataTransformer\DataTransformerInterface;
2829
use ApiPlatform\Core\Exception\RuntimeException;
2930
use Doctrine\Common\Annotations\Annotation;
3031
use Doctrine\ORM\Version;
@@ -150,6 +151,7 @@ public function load(array $configs, ContainerBuilder $container)
150151
$this->registerMercureConfiguration($container, $config, $loader, $useDoctrine);
151152
$this->registerMessengerConfiguration($config, $loader);
152153
$this->registerElasticsearchConfiguration($container, $config, $loader);
154+
$this->registerDataTransformerConfiguration($container);
153155
}
154156

155157
/**
@@ -603,4 +605,10 @@ private function registerElasticsearchConfiguration(ContainerBuilder $container,
603605
$container->setParameter('api_platform.elasticsearch.hosts', $config['elasticsearch']['hosts']);
604606
$container->setParameter('api_platform.elasticsearch.mapping', $config['elasticsearch']['mapping']);
605607
}
608+
609+
private function registerDataTransformerConfiguration(ContainerBuilder $container)
610+
{
611+
$container->registerForAutoconfiguration(DataTransformerInterface::class)
612+
->addTag('api_platform.data_transformer');
613+
}
606614
}

tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
use ApiPlatform\Core\DataProvider\CollectionDataProviderInterface;
5555
use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
5656
use ApiPlatform\Core\DataProvider\SubresourceDataProviderInterface;
57+
use ApiPlatform\Core\DataTransformer\DataTransformerInterface;
5758
use ApiPlatform\Core\Exception\FilterValidationException;
5859
use ApiPlatform\Core\Exception\InvalidArgumentException;
5960
use ApiPlatform\Core\Exception\RuntimeException;
@@ -877,6 +878,10 @@ private function getBaseContainerBuilderProphecy()
877878
->willReturn($this->childDefinitionProphecy)->shouldBeCalledTimes(1);
878879
$this->childDefinitionProphecy->addTag('api_platform.doctrine.mongodb.aggregation_extension.collection')->shouldBeCalledTimes(1);
879880

881+
$containerBuilderProphecy->registerForAutoconfiguration(DataTransformerInterface::class)
882+
->willReturn($this->childDefinitionProphecy)->shouldBeCalledTimes(1);
883+
$this->childDefinitionProphecy->addTag('api_platform.data_transformer')->shouldBeCalledTimes(1);
884+
880885
$containerBuilderProphecy->addResource(Argument::type(DirectoryResource::class))->shouldBeCalled();
881886

882887
$parameters = [

0 commit comments

Comments
 (0)