Commit d1513ead authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Modif service Acteur: possibilité de spécifier le paramètre 'these_id'.

parent e262d9b3
<?php <?php
use ImportData\V1\Rest\Acteur\ActeurFetchAll;
return [ return [
'doctrine' => [ 'doctrine' => [
'driver' => [ 'driver' => [
...@@ -18,6 +20,14 @@ return [ ...@@ -18,6 +20,14 @@ return [
], ],
], ],
], ],
'zf-apigility-doctrine-query-provider' => [
'aliases' => [
'acteur_fetch_all' => ActeurFetchAll::class,
],
'factories' => [
ActeurFetchAll::class => \Zend\ServiceManager\Factory\InvokableFactory::class,
],
],
'router' => [ 'router' => [
'routes' => [ 'routes' => [
'import-data.rest.doctrine.these' => [ 'import-data.rest.doctrine.these' => [
...@@ -206,7 +216,9 @@ return [ ...@@ -206,7 +216,9 @@ return [
'collection_http_methods' => [ 'collection_http_methods' => [
0 => 'GET', 0 => 'GET',
], ],
'collection_query_whitelist' => [], 'collection_query_whitelist' => [
0 => 'these_id',
],
'page_size' => '250000000000000000000', 'page_size' => '250000000000000000000',
'page_size_param' => null, 'page_size_param' => null,
'entity_class' => \ImportData\V1\Entity\Db\Acteur::class, 'entity_class' => \ImportData\V1\Entity\Db\Acteur::class,
...@@ -438,6 +450,10 @@ return [ ...@@ -438,6 +450,10 @@ return [
0 => 'application/json', 0 => 'application/json',
1 => 'application/*+json', 1 => 'application/*+json',
], ],
'ImportData\\V1\\Rest\\Acteur\\Controller' => [
0 => 'application/json',
1 => 'application/*+json',
],
], ],
'content_type_whitelist' => [ 'content_type_whitelist' => [
'ImportData\\V1\\Rest\\Structure\\Controller' => [ 'ImportData\\V1\\Rest\\Structure\\Controller' => [
...@@ -452,6 +468,9 @@ return [ ...@@ -452,6 +468,9 @@ return [
'ImportData\\V1\\Rest\\UniteRecherche\\Controller' => [ 'ImportData\\V1\\Rest\\UniteRecherche\\Controller' => [
0 => 'application/json', 0 => 'application/json',
], ],
'ImportData\\V1\\Rest\\Acteur\\Controller' => [
0 => 'application/json',
],
], ],
], ],
'zf-hal' => [ 'zf-hal' => [
...@@ -596,6 +615,10 @@ return [ ...@@ -596,6 +615,10 @@ return [
\ImportData\V1\Rest\Acteur\ActeurResource::class => [ \ImportData\V1\Rest\Acteur\ActeurResource::class => [
'object_manager' => 'doctrine.entitymanager.orm_default', 'object_manager' => 'doctrine.entitymanager.orm_default',
'hydrator' => 'ImportData\\V1\\Rest\\Acteur\\ActeurHydrator', 'hydrator' => 'ImportData\\V1\\Rest\\Acteur\\ActeurHydrator',
'query_providers' => [
'default' => 'default_orm',
'fetch_all' => 'acteur_fetch_all',
],
], ],
\ImportData\V1\Rest\Role\RoleResource::class => [ \ImportData\V1\Rest\Role\RoleResource::class => [
'object_manager' => 'doctrine.entitymanager.orm_default', 'object_manager' => 'doctrine.entitymanager.orm_default',
......
<?php
namespace ImportData\V1\Rest\Acteur;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use ZF\Apigility\Doctrine\Server\Query\Provider\AbstractQueryProvider;
use ZF\Rest\ResourceEvent;
class ActeurFetchAll extends AbstractQueryProvider
{
/**
* @param ResourceEvent $event
* @param string $entityClass
* @param array $parameters
* @return QueryBuilder
*/
public function createQuery(ResourceEvent $event, $entityClass, $parameters)
{
/** @var EntityRepository $repo */
$repo = $this->getObjectManager()->getRepository($entityClass);
$qb = $repo->createQueryBuilder('a');
if (isset($parameters['these_id'])) {
$qb
->andWhere('a.theseId = :theseId')
->setParameter('theseId', $parameters['these_id']);
}
return $qb;
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment