You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Data Provider Exception vs Restricted interface (#1197)
* Data Provider seems misused
Conflict between ApiPlatform\Core\Exception\ResourceClassNotSupportedException and ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface usages
* Update data-providers.md
Copy file name to clipboardExpand all lines: core/data-providers.md
+1-6Lines changed: 1 addition & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,6 @@ namespace App\DataProvider;
40
40
41
41
use ApiPlatform\Core\DataProvider\ContextAwareCollectionDataProviderInterface;
42
42
use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
43
-
use ApiPlatform\Core\Exception\ResourceClassNotSupportedException;
44
43
use App\Entity\BlogPost;
45
44
46
45
final class BlogPostCollectionDataProvider implements ContextAwareCollectionDataProviderInterface, RestrictedDataProviderInterface
@@ -74,8 +73,7 @@ services:
74
73
75
74
Tagging the service with the tag `api_platform.collection_data_provider` will enable API Platform Core to automatically
76
75
register and use this data provider. The optional attribute `priority` allows you to define the order in which the
77
-
data providers are called. The first data provider not throwing a `ApiPlatform\Core\Exception\ResourceClassNotSupportedException`
78
-
will be used.
76
+
data providers are called. Implementing the `ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface` let you restrict the data provider use. Alternatively, you can also throw a `ApiPlatform\Core\Exception\ResourceClassNotSupportedException`. Without the `RestrictedDataProviderInterface`, the first data provider not throwing this exception will be used.
79
77
80
78
You can find a full working example in the [API Platform's demo application](https://github.com/api-platform/demo/blob/master/api/src/DataProvider/TopBookCollectionDataProvider.php).
81
79
@@ -94,7 +92,6 @@ namespace App\DataProvider;
94
92
95
93
use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
96
94
use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
97
-
use ApiPlatform\Core\Exception\ResourceClassNotSupportedException;
98
95
use App\Entity\BlogPost;
99
96
100
97
final class BlogPostItemDataProvider implements ItemDataProviderInterface, RestrictedDataProviderInterface
@@ -145,7 +142,6 @@ namespace App\DataProvider;
145
142
use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
146
143
use ApiPlatform\Core\DataProvider\SerializerAwareDataProviderInterface;
147
144
use ApiPlatform\Core\DataProvider\SerializerAwareDataProviderTrait;
148
-
use ApiPlatform\Core\Exception\ResourceClassNotSupportedException;
149
145
use App\Entity\BlogPost;
150
146
151
147
final class BlogPostItemDataProvider implements ItemDataProviderInterface, SerializerAwareDataProviderInterface
@@ -203,7 +199,6 @@ use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryResultItemExtensionInter
203
199
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGenerator;
204
200
use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
205
201
use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
206
-
use ApiPlatform\Core\Exception\ResourceClassNotSupportedException;
0 commit comments