zfcampus / zf-doctrine-querybuilder

Doctrine Query Builder request Filters
BSD 3-Clause "New" or "Revised" License
32 stars 19 forks source link

Fixed query providers with proper extends #7

Closed TomHAnderson closed 9 years ago

TomHAnderson commented 9 years ago

The query providers had not been updated to extend from the base query providers of zf-apigility-doctrine.

This is in reply to https://github.com/zfcampus/zf-doctrine-querybuilder/pull/6

TomHAnderson commented 9 years ago

@renooo does this fix the issue you were having? This module did fall behind zf-apigility-doctrine Query Providers and there are still no tests for the providers included here.

renooo commented 9 years ago

I tried with your code for ZF\Doctrine\QueryBuilder\Query\Provider\DefaultOrm and it doesn't work.

PHP Catchable fatal error:  Argument 1 passed to ZF\Apigility\Doctrine\Server\Query\Provider\DefaultOrm::createQuery() must be an instance of ZF\Rest\ResourceEvent, none given, called in [...]/vendor/zfcampus/zf-doctrine-querybuilder/src/Query/Provider/DefaultOrm.php on line 51 and defined in [...]/vendor/zfcampus/zf-apigility-doctrine/src/Server/Query/Provider/DefaultOrm.php on line 23
renooo commented 9 years ago

But it works with https://github.com/zfcampus/zf-doctrine-querybuilder/pull/6

I'll try to write somme tests soon.

TomHAnderson commented 9 years ago

I didn't pass params to the parent::createQuery Give this one a try please.

renooo commented 9 years ago

It fails with :

PHP Fatal error: Cannot use object of type ZF\ContentNegotiation\Request as array in [...]/vendor/zfcampus/zf-doctrine-querybuilder/src/Query/Provider/DefaultOrm.php on line 58

TomHAnderson commented 9 years ago

Thanks for the patience. I wasn't extracting the getQuery()->toArray() from the request. I think this'll fix it.

renooo commented 9 years ago

ZF\\Apigility\\Doctrine\\Server\\Query\\Provider\\Service\\QueryProviderManager::get was unable to fetch or create an instance for ZfDoctrineQueryBuilderFilterManagerOrm

Because you have a dedicated Manager in this context, a kind of "sub-ServiceLocator", this is not enough :

$filterManager = $this->getServiceLocator()->get('ZfDoctrineQueryBuilderFilterManagerOrm');

You need to do :

$filterManager = $this->getServiceLocator()->getServiceLocator()->get('ZfDoctrineQueryBuilderFilterManagerOrm');
renooo commented 9 years ago

Actually :

            $filterManager = $this->getServiceLocator()
                                  ->getServiceLocator()
                                  ->get('ZfDoctrineQueryBuilderFilterManagerOrm');

and :

            $orderByManager = $this->getServiceLocator()
                                   ->getServiceLocator()
                                   ->get('ZfDoctrineQueryBuilderOrderByManagerOrm');
TomHAnderson commented 9 years ago

I added these as a convenience and I hope they start becoming so after this fix.

renooo commented 9 years ago

It works like a charm both for filter and orderBy. Thank you very much !

mrVrAlex commented 9 years ago

Hello, When it will be merge to master branch? After updating zf-apigility-doctrine to latest stable version I got this error:

 PHP Fatal error:  Call to undefined method ZF\Doctrine\QueryBuilder\Query\Provider\DefaultOrm::setOAuth2Server() in /var/www/frontend/shared/vendor/zfcampus/zf-apigility-doctrine/src/Server/Resource/DoctrineResourceFactory.php on line 276

If use develop branch zf-doctrine-querybuilder this works fine.