Comments (7)
This feature has been partially contributed by @amenophis in #44
It can be features 2 + 3 + 4 :)
from core.
Ok, just waiting for you to finish the doc before closing this ticket then.
from core.
@dunglas since the PR has been merged and from what I see all the features has been added by now but I do not see it in the doc though.
from core.
I was thinking of updating the doc. Should I put it in a dedicated chapter or to append it in an existing one?
from core.
Update on the issue:
1 +3 is already handled and documented here.
1 + 2 is possible be requires to declare a custom DataProvider
like the following:
resource.dummy.data_provider:
class: Dunglas\ApiBundle\Doctrine\Orm\DataProvider
arguments:
- @doctrine
- %api.collection.order%
- %api.collection.pagination.page_parameter_name%
- %api.collection.pagination.items_per_page.number%
- %api.collection.pagination.items_per_page.enable_client_request%
- %api.collection.pagination.items_per_page.parameter_name%
resource.dummy:
parent: api.resource
arguments: [ AppBundle\Entity\Dummy, @resource.dummy.data_provider ]
The above use the default parameters specified in the config, to override them is just needed to put the wished value.
But doing so is quite verbose and tedious if one want to do so for several entities. At the moment, the simpliest way I've found is to roll out my own DataProvider
, adding some initX
methods to play with the parameters and declaring it as abstract. Then I just have to declare a new data provider for my resource using this new data provider as a parent and doing calls to change only the parameters wished:
api.extended_data_provider:
class: DataProvider\ExtendedDataProvider
abstract: true
arguments:
- @doctrine
- %api.collection.order%
- %api.collection.pagination.page_parameter_name%
- %api.collection.pagination.items_per_page.number%
- %api.collection.pagination.items_per_page.enable_client_request%
- %api.collection.pagination.items_per_page.parameter_name%
resource.dummy.data_provider:
parent: api.extended_data_provider
calls:
- [ initEnableClientRequestItemsPerPage, [ true ] ]
tags: [ { name: api.data_provider } ]
resource.dummy:
parent: api.resource
arguments: [ AppBundle\Entity\Dummy, @resource.dummy.data_provider ]
In both cases I'm quite unhappy with the process: it's too much for such simple task. Would it be possible to add directly those initX
methods in the bundle DataProvider
? Unless you see another way, that would imply to also add an abstract service, but at least it 1 + 2 does not feel like hacking the bundle and risking to break everything at every change of the bundle DataProvider
anymore.
In both cases, since this is a complete and concrete use case, a dedicated documentation should be available.
To recap:
- Dedicated documentation for the four use cases
- Decide on the approach to handle the 1 + 2 use case in a better way
from core.
Goes with #131
from core.
Done in v2.
from core.
Related Issues (20)
- Swagger Docs jsonopenapi format return HTML HOT 5
- Mixing IRIs between resources and sub-resources when using DTO HOT 2
- Doctrine ODM SearchFilter with embedded documents HOT 3
- Asset mapper warnings HOT 9
- Attempted to call an undefined method named "withParameterName" of class "ApiPlatform\Metadata\ApiProperty" HOT 1
- OpenAPI on calculated field add an extra `items` fields even if `openApiContext` define an object HOT 3
- Validation doesn't work proppperly with strict types HOT 1
- Add a way to configure default strategy mode for the SearchFilter
- Handle null request in ReadProvider HOT 1
- Upgrade to Symfony 7.1 seems to be breaking container linting
- Broken with symfony 7.1 HOT 2
- Unable to generate an IRI for the item of type App\ApiResource\*** with an UriTemplate HOT 1
- Support for JsonProblem (RFC 7807) Extension Member HOT 2
- Remove hydra prefix
- Filters incompatible with PHP 8.2.20 and 8.3.8 HOT 22
- Implement getType for ODM DoctrineExtractor HOT 1
- Mixing REST and GraphQL operation names HOT 3
- Access checks for a DTO created through a resolver should happen after it was created HOT 2
- Doctrine ODM Documents return inconsistent data for GET Collection and Item Operations in Symfony production environment HOT 1
- Calling GraphQL DeleteMutation ignores serialization groups and causes error HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.