Skip to content

Commit f9b7ff3

Browse files
committed
Merge branch '2.1'
2 parents fcdcb5c + 53f12b2 commit f9b7ff3

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

src/Bridge/Symfony/Bundle/Resources/config/doctrine_orm.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,15 @@
117117
<tag name="api_platform.doctrine.orm.query_extension.item" priority="64" />
118118
<tag name="api_platform.doctrine.orm.query_extension.collection" priority="64" />
119119
</service>
120+
<service id="ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\EagerLoadingExtension" alias="api_platform.doctrine.orm.query_extension.eager_loading" />
120121

121122
<service id="api_platform.doctrine.orm.query_extension.filter" class="ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\FilterExtension" public="false">
122123
<argument type="service" id="api_platform.metadata.resource.metadata_factory" />
123124
<argument type="service" id="api_platform.filter_locator" />
124125

125126
<tag name="api_platform.doctrine.orm.query_extension.collection" priority="32" />
126127
</service>
128+
<service id="ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\FilterExtension" alias="api_platform.doctrine.orm.query_extension.filter" />
127129

128130
<!-- This needs to be executed right after the filter extension -->
129131

@@ -133,6 +135,7 @@
133135

134136
<tag name="api_platform.doctrine.orm.query_extension.collection" priority="31" />
135137
</service>
138+
<service id="ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\FilterEagerLoadingExtension" alias="api_platform.doctrine.orm.query_extension.filter_eager_loading" />
136139

137140
<service id="api_platform.doctrine.orm.query_extension.pagination" class="ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\PaginationExtension" public="false">
138141
<argument type="service" id="doctrine" />
@@ -152,13 +155,15 @@
152155

153156
<tag name="api_platform.doctrine.orm.query_extension.collection" priority="8" />
154157
</service>
158+
<service id="ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\PaginationExtension" alias="api_platform.doctrine.orm.query_extension.pagination" />
155159

156160
<service id="api_platform.doctrine.orm.query_extension.order" class="ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\OrderExtension" public="false">
157161
<argument>%api_platform.collection.order%</argument>
158162
<argument type="service" id="api_platform.metadata.resource.metadata_factory" />
159163

160164
<tag name="api_platform.doctrine.orm.query_extension.collection" priority="16" />
161165
</service>
166+
<service id="ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\OrderExtension" alias="api_platform.doctrine.orm.query_extension.order" />
162167
</services>
163168

164169
</container>

src/Bridge/Symfony/Bundle/Resources/config/metadata/metadata.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<argument type="service" id="api_platform.cache.metadata.resource" />
1212
<argument type="service" id="api_platform.metadata.resource.name_collection_factory.cached.inner" />
1313
</service>
14+
<service id="ApiPlatform\Core\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface" alias="api_platform.metadata.resource.name_collection_factory" />
1415

1516
<!-- Resource metadata -->
1617

@@ -28,9 +29,12 @@
2829
<argument type="service" id="api_platform.metadata.resource.metadata_factory.cached.inner" />
2930
</service>
3031

32+
<service id="ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface" alias="api_platform.metadata.resource.metadata_factory" />
33+
3134
<!-- Property name collection -->
3235

3336
<service id="api_platform.metadata.property.name_collection_factory" alias="api_platform.metadata.property.name_collection_factory.property_info" />
37+
<service id="ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface" alias="api_platform.metadata.property.name_collection_factory" />
3438

3539
<service id="api_platform.metadata.property.name_collection_factory.property_info" class="ApiPlatform\Core\Bridge\Symfony\PropertyInfo\Metadata\Property\PropertyInfoPropertyNameCollectionFactory" public="false">
3640
<argument type="service" id="api_platform.property_info" />
@@ -70,6 +74,8 @@
7074
<argument type="service" id="api_platform.metadata.property.metadata_factory.cached.inner" />
7175
</service>
7276

77+
<service id="ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface" alias="api_platform.metadata.property.metadata_factory" />
78+
7379
<!-- Cache -->
7480

7581
<service id="api_platform.cache.metadata.resource" parent="cache.system" public="false">

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

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515

1616
use ApiPlatform\Core\Api\FilterInterface;
1717
use ApiPlatform\Core\Api\IriConverterInterface;
18+
use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\EagerLoadingExtension;
19+
use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\FilterEagerLoadingExtension;
20+
use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\FilterExtension;
21+
use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\OrderExtension;
22+
use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\PaginationExtension;
1823
use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryCollectionExtensionInterface;
1924
use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
2025
use ApiPlatform\Core\Bridge\Symfony\Bundle\DependencyInjection\ApiPlatformExtension;
@@ -23,6 +28,10 @@
2328
use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
2429
use ApiPlatform\Core\DataProvider\SubresourceDataProviderInterface;
2530
use ApiPlatform\Core\Exception\InvalidArgumentException;
31+
use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
32+
use ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
33+
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface;
34+
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface;
2635
use ApiPlatform\Core\Serializer\SerializerContextBuilderInterface;
2736
use ApiPlatform\Core\Tests\Fixtures\TestBundle\TestBundle;
2837
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
@@ -267,7 +276,7 @@ public function testResourcesToWatchWithUnsupportedMappingType()
267276
{
268277
$this->extension->load(
269278
array_merge_recursive(self::DEFAULT_CONFIG, ['api_platform' => ['mapping' => ['paths' => [__FILE__]]]]),
270-
$this->getPartialContainerBuilderProphecy()->reveal()
279+
$this->getPartialContainerBuilderProphecy(false)->reveal()
271280
);
272281
}
273282

@@ -304,7 +313,7 @@ public function testNotRegisterHttpCacheWhenEnabledWithNoVarnishServer()
304313
$this->extension->load($config, $containerBuilder);
305314
}
306315

307-
private function getPartialContainerBuilderProphecy()
316+
private function getPartialContainerBuilderProphecy($test = false)
308317
{
309318
$containerBuilderProphecy = $this->prophesize(ContainerBuilder::class);
310319
$childDefinitionProphecy = $this->prophesize(ChildDefinition::class);
@@ -494,6 +503,10 @@ private function getPartialContainerBuilderProphecy()
494503
ItemDataProviderInterface::class => 'api_platform.item_data_provider',
495504
SubresourceDataProviderInterface::class => 'api_platform.subresource_data_provider',
496505
DataPersisterInterface::class => 'api_platform.data_persister',
506+
ResourceNameCollectionFactoryInterface::class => 'api_platform.metadata.resource.name_collection_factory',
507+
ResourceMetadataFactoryInterface::class => 'api_platform.metadata.resource.metadata_factory',
508+
PropertyNameCollectionFactoryInterface::class => 'api_platform.metadata.property.name_collection_factory',
509+
PropertyMetadataFactoryInterface::class => 'api_platform.metadata.property.metadata_factory',
497510
];
498511

499512
foreach ($aliases as $alias => $service) {
@@ -624,7 +637,18 @@ private function getBaseContainerBuilderProphecy()
624637
$containerBuilderProphecy->setDefinition($definition, Argument::type(Definition::class))->shouldBeCalled();
625638
}
626639

627-
$containerBuilderProphecy->setAlias('api_platform.http_cache.purger', 'api_platform.http_cache.purger.varnish')->shouldBeCalled();
640+
$aliases = [
641+
'api_platform.http_cache.purger' => 'api_platform.http_cache.purger.varnish',
642+
EagerLoadingExtension::class => 'api_platform.doctrine.orm.query_extension.eager_loading',
643+
FilterExtension::class => 'api_platform.doctrine.orm.query_extension.filter',
644+
FilterEagerLoadingExtension::class => 'api_platform.doctrine.orm.query_extension.filter_eager_loading',
645+
PaginationExtension::class => 'api_platform.doctrine.orm.query_extension.pagination',
646+
OrderExtension::class => 'api_platform.doctrine.orm.query_extension.order',
647+
];
648+
649+
foreach ($aliases as $alias => $service) {
650+
$containerBuilderProphecy->setAlias($alias, $service)->shouldBeCalled();
651+
}
628652

629653
return $containerBuilderProphecy;
630654
}

0 commit comments

Comments
 (0)