Skip to content

Add query extension when using custom data provider#1751

Closed
ad3n wants to merge 3 commits into
api-platform:masterfrom
ad3n:patch-1
Closed

Add query extension when using custom data provider#1751
ad3n wants to merge 3 commits into
api-platform:masterfrom
ad3n:patch-1

Conversation

@ad3n

@ad3n ad3n commented Mar 7, 2018

Copy link
Copy Markdown
Contributor

When using custom data provider the query extensions is not working properly. By applying this PR, we can inject the query extension based on service tag.

But we have problem with autowire service because the compiler execute before autowire, can you help us to fix this problem?

Q A
Bug fix? yes
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR [need doc change]

Please update this template with something that matches your PR

ad3n added 3 commits March 7, 2018 07:05
When using custom data provider the query extensions is not working properly. By applying this PR, we can inject the query extension based on service tag.

But we have problem with autowire service because the compiler execute before autowire, can you help us to fix this problem?
update
bugfix
@soyuka

soyuka commented Mar 7, 2018

Copy link
Copy Markdown
Member

Custom data providers are different from the core ones.

If you want extensions just inject the one you need. If your demand is to have an injectable collection of all the available extensions we can add it.

For example:

  1. Declare a traversable class (which will be holding the extensions)
  2. Inject every extensions in it
  3. Declare this as a reusable service

@ad3n

ad3n commented Mar 7, 2018

Copy link
Copy Markdown
Contributor Author

@soyuka : Thanks for your comment. But how to inject the extension to custom data provider because we don't have bundle in app?

@meyerbaptiste

Copy link
Copy Markdown
Member

I'm not sure to understand your question. If you want to inject specific extensions, use the service definition, if you want to inject all the extensions use a compiler pass. In any case, it works fine without bundle.

@soyuka

soyuka commented Mar 7, 2018

Copy link
Copy Markdown
Member

@meyerbaptiste we maybe should expose a class that has every extensions it it. Would be easier to reuse no?

@meyerbaptiste

meyerbaptiste commented Mar 7, 2018

Copy link
Copy Markdown
Member

I'm agree with you, it would be a good idea to have a service/class, which implements the \Traversable interface, rather than an array.

@ad3n

ad3n commented Mar 9, 2018

Copy link
Copy Markdown
Contributor Author

@soyuka : 👍 i agree to use the traversable but you need to modify the doc to mention how to apply filter and/or extension in custom data provider because it is confusing when we create a custom data provider and the filter is gone and we don't know about it until we check the compiler pass...

for new comer, it is hard to debug...

Or use an interface to inject the extension automaticly

@soyuka

soyuka commented Mar 9, 2018

Copy link
Copy Markdown
Member

Indeed, it'll be easier to do and to document!

@dunglas

dunglas commented Apr 1, 2018

Copy link
Copy Markdown
Member

I don't understand the question nor the use case. Why do we need a new class? Isn't https://symfony.com/blog/new-in-symfony-3-4-simpler-injection-of-tagged-services enough?

@soyuka

soyuka commented Apr 1, 2018

Copy link
Copy Markdown
Member

oh yes this is nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants