zfcampus/zf-apigility-doctrine — pull request #76 by veewee (2014-04-17 13:53:25+00:00)
Title: Make the query collection provider configurable

This PR will fix issue https://github.com/zfcampus/zf-apigility-doctrine/issues/75
It will make it is possible to add new query objects. When no query object is provided, there will be a fallback to the default ODM and ORM query objects.

# Example:

Config:
```php
'zf-collection-query' => array(
'invokables' => array(
'custom-query-provider' => 'Application\My\Custom\Query',
)
),
'zf-apigility' => array(
'doctrine-connected' => array(
'Api\\V1\\Rest\\Users\\UserResource' => array(
'object_manager' => 'doctrine.documentmanager.odm_default',
'hydrator' => 'TenantApi\\V1\\Rest\\Users\\UsersHydrator',
'query_provider' => 'custom-query-provider',
),
),
),
```

Class:
```php
namespace Application\My\Custom;
use ZF\Apigility\Doctrine\Server\Collection\Query\FetchAllOdmQuery;
class Query extends FetchAllOdmQuery
{
public function createQuery($entityClass, array $parameters)
{
$queryBuilder = parent::createQuery($entityClass, $parameters);
$queryBuilder->andWhere($queryBuilder->expr()->field('field')->notEqual('value'));
return $queryBuilder
}

}
```