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

Correction du tri des données retournées : implémentation du order-by via un...

Correction du tri des données retournées : implémentation du order-by via un query provider par défaut.
Le module zf-doctrine-querybuilder utilisé auparavant ne fonctionnait pas comme prévu donc il a été abandonné car il n'apporte rien.
parent 0d4af394
......@@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "3afec53d1de13c19dfa549c231b47667",
"content-hash": "ec968e437048d805e7787e06016a2233",
"packages": [
{
"name": "api-skeletons/zf-doctrine-module-zend-hydrator",
"version": "1.0.0",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/API-Skeletons/zf-doctrine-module-zend-hydrator.git",
"reference": "9041810ef43f37e3526941cef471970cbd65cf92"
"reference": "5de0c3f53cd7de347fb52d09524062aaf6e5abf9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/API-Skeletons/zf-doctrine-module-zend-hydrator/zipball/9041810ef43f37e3526941cef471970cbd65cf92",
"reference": "9041810ef43f37e3526941cef471970cbd65cf92",
"url": "https://api.github.com/repos/API-Skeletons/zf-doctrine-module-zend-hydrator/zipball/5de0c3f53cd7de347fb52d09524062aaf6e5abf9",
"reference": "5de0c3f53cd7de347fb52d09524062aaf6e5abf9",
"shasum": ""
},
"require": {
......@@ -41,7 +41,7 @@
}
],
"description": "Corrects DoctrineModule classes to use zend-hydrator",
"time": "2016-06-12T20:55:02+00:00"
"time": "2018-09-08T19:28:12+00:00"
},
{
"name": "bshaffer/oauth2-server-php",
......@@ -1309,16 +1309,16 @@
},
{
"name": "symfony/console",
"version": "v3.4.15",
"version": "v3.4.17",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "6b217594552b9323bcdcfc14f8a0ce126e84cd73"
"reference": "3b2b415d4c48fbefca7dc742aa0a0171bfae4e0b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/6b217594552b9323bcdcfc14f8a0ce126e84cd73",
"reference": "6b217594552b9323bcdcfc14f8a0ce126e84cd73",
"url": "https://api.github.com/repos/symfony/console/zipball/3b2b415d4c48fbefca7dc742aa0a0171bfae4e0b",
"reference": "3b2b415d4c48fbefca7dc742aa0a0171bfae4e0b",
"shasum": ""
},
"require": {
......@@ -1374,20 +1374,20 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2018-07-26T11:19:56+00:00"
"time": "2018-10-02T16:33:53+00:00"
},
{
"name": "symfony/debug",
"version": "v3.4.15",
"version": "v3.4.17",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
"reference": "c4625e75341e4fb309ce0c049cbf7fb84b8897cd"
"reference": "0a612e9dfbd2ccce03eb174365f31ecdca930ff6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/c4625e75341e4fb309ce0c049cbf7fb84b8897cd",
"reference": "c4625e75341e4fb309ce0c049cbf7fb84b8897cd",
"url": "https://api.github.com/repos/symfony/debug/zipball/0a612e9dfbd2ccce03eb174365f31ecdca930ff6",
"reference": "0a612e9dfbd2ccce03eb174365f31ecdca930ff6",
"shasum": ""
},
"require": {
......@@ -1430,7 +1430,7 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2018-08-03T10:42:44+00:00"
"time": "2018-10-02T16:33:53+00:00"
},
{
"name": "symfony/polyfill-mbstring",
......@@ -1493,11 +1493,11 @@
},
{
"name": "unicaen/oracle",
"version": "1.2.0",
"version": "1.2.1",
"source": {
"type": "git",
"url": "https://git.unicaen.fr/lib/unicaen/oracle.git",
"reference": "42efd5f206ba5547a62ae48c79ce57706272d3be"
"reference": "fc16a7394c40ffa50324f7028e90431f9ecae12a"
},
"require": {
"doctrine/dbal": "^2.5",
......@@ -1517,7 +1517,7 @@
]
},
"description": "Bibliothèque utile lorsqu'on utilise un base de données Oracle",
"time": "2018-04-27T08:31:56+00:00"
"time": "2018-09-11T07:47:55+00:00"
},
{
"name": "zendframework/zend-authentication",
......@@ -2919,16 +2919,16 @@
},
{
"name": "zendframework/zend-stdlib",
"version": "3.2.0",
"version": "3.2.1",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-stdlib.git",
"reference": "cd164b4a18b5d1aeb69be2c26db035b5ed6925ae"
"reference": "66536006722aff9e62d1b331025089b7ec71c065"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/cd164b4a18b5d1aeb69be2c26db035b5ed6925ae",
"reference": "cd164b4a18b5d1aeb69be2c26db035b5ed6925ae",
"url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/66536006722aff9e62d1b331025089b7ec71c065",
"reference": "66536006722aff9e62d1b331025089b7ec71c065",
"shasum": ""
},
"require": {
......@@ -2961,7 +2961,7 @@
"stdlib",
"zf"
],
"time": "2018-04-30T13:50:40+00:00"
"time": "2018-08-28T21:34:05+00:00"
},
{
"name": "zendframework/zend-uri",
......@@ -3795,80 +3795,6 @@
],
"time": "2018-05-07T15:44:42+00:00"
},
{
"name": "zfcampus/zf-doctrine-querybuilder",
"version": "1.6.0",
"source": {
"type": "git",
"url": "https://github.com/zfcampus/zf-doctrine-querybuilder.git",
"reference": "bf24e8ff48f8ae6f072e1237cc7c15074d3954f1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zfcampus/zf-doctrine-querybuilder/zipball/bf24e8ff48f8ae6f072e1237cc7c15074d3954f1",
"reference": "bf24e8ff48f8ae6f072e1237cc7c15074d3954f1",
"shasum": ""
},
"require": {
"doctrine/doctrine-module": "^1.2",
"php": "^5.6 || ^7.0",
"zendframework/zend-hydrator": "^1.1 || ^2.2.1",
"zendframework/zend-modulemanager": "^2.7.2",
"zendframework/zend-mvc": "^2.7.13 || ^3.0.2",
"zendframework/zend-servicemanager": "^2.7.6 || ^3.1.1",
"zfcampus/zf-api-problem": "^1.2.2",
"zfcampus/zf-apigility-doctrine": "^2.1",
"zfcampus/zf-hal": "^1.4.2"
},
"require-dev": {
"doctrine/doctrine-mongo-odm-module": "^1.0",
"doctrine/doctrine-orm-module": "^1.1",
"phpunit/phpunit": "^5.7.26",
"zendframework/zend-coding-standard": "~1.0.0",
"zendframework/zend-i18n": "^2.7.3",
"zendframework/zend-log": "^2.9.1",
"zendframework/zend-serializer": "^2.8",
"zendframework/zend-test": "^2.6.1 || ^3.0.1",
"zfcampus/zf-apigility-provider": "^1.2"
},
"suggest": {
"doctrine/doctrine-mongo-odm-module": "^1.0, if you wish to use the Doctrine ODM",
"doctrine/doctrine-orm-module": "^1.1, if you wish to use the Doctrine ORM",
"ext/mongo": "Mongo extension, if using ODM"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.6-dev",
"dev-develop": "1.7-dev"
},
"zf": {
"module": [
"ZF\\Doctrine\\QueryBuilder"
]
}
},
"autoload": {
"psr-4": {
"ZF\\Doctrine\\QueryBuilder\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Apigility Doctrine QueryBuilder module",
"homepage": "https://apigility.org",
"keywords": [
"ZendFramework",
"api",
"apigility",
"doctrine",
"filter",
"zf"
],
"time": "2018-01-17T12:57:48+00:00"
},
{
"name": "zfcampus/zf-hal",
"version": "1.5.0",
......@@ -4784,16 +4710,16 @@
},
{
"name": "zfcampus/zf-apigility-admin-ui",
"version": "1.3.9",
"version": "1.3.11",
"source": {
"type": "git",
"url": "https://github.com/zfcampus/zf-apigility-admin-ui.git",
"reference": "20f5b79643c00fdc9b8e3ddd33d9700a9240ccd6"
"reference": "4b4435296fa40d7ad2b5d1397a219fb5cbf72140"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zfcampus/zf-apigility-admin-ui/zipball/20f5b79643c00fdc9b8e3ddd33d9700a9240ccd6",
"reference": "20f5b79643c00fdc9b8e3ddd33d9700a9240ccd6",
"url": "https://api.github.com/repos/zfcampus/zf-apigility-admin-ui/zipball/4b4435296fa40d7ad2b5d1397a219fb5cbf72140",
"reference": "4b4435296fa40d7ad2b5d1397a219fb5cbf72140",
"shasum": ""
},
"require": {
......@@ -4831,7 +4757,7 @@
"framework",
"zf2"
],
"time": "2016-12-19T17:46:02+00:00"
"time": "2018-09-10T21:22:02+00:00"
},
{
"name": "zfcampus/zf-console",
......
<?php
/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c] 2013-2016 Zend Technologies USA Inc. (http://www.zend.com]
*/
namespace ZF\Doctrine\QueryBuilder;
use Zend\ServiceManager\Factory\InvokableFactory;
return [
// 'zf-apigility-doctrine-query-provider' => [
// 'aliases' => [
// 'default_orm' => Query\Provider\DefaultOrm::class,
// 'default_odm' => Query\Provider\DefaultOdm::class,
// ],
// 'factories' => [
// Query\Provider\DefaultOrm::class => Query\Provider\DefaultOrmFactory::class,
// Query\Provider\DefaultOdm::class => Query\Provider\DefaultOdmFactory::class,
// ],
// ],
'zf-doctrine-querybuilder-options' => [
'filter_key' => 'filter',
'order_by_key' => 'order-by',
],
'zf-doctrine-querybuilder-orderby-orm' => [
'aliases' => [
'field' => OrderBy\ORM\Field::class,
],
'factories' => [
OrderBy\ORM\Field::class => InvokableFactory::class,
],
],
'zf-doctrine-querybuilder-orderby-odm' => [
'aliases' => [
'field' => OrderBy\ODM\Field::class,
],
'factories' => [
OrderBy\ODM\Field::class => InvokableFactory::class,
],
],
'zf-doctrine-querybuilder-filter-orm' => [
'aliases' => [
'eq' => Filter\ORM\Equals::class,
'neq' => Filter\ORM\NotEquals::class,
'lt' => Filter\ORM\LessThan::class,
'lte' => Filter\ORM\LessThanOrEquals::class,
'gt' => Filter\ORM\GreaterThan::class,
'gte' => Filter\ORM\GreaterThanOrEquals::class,
'isnull' => Filter\ORM\IsNull::class,
'isnotnull' => Filter\ORM\IsNotNull::class,
'in' => Filter\ORM\In::class,
'notin' => Filter\ORM\NotIn::class,
'between' => Filter\ORM\Between::class,
'like' => Filter\ORM\Like::class,
'notlike' => Filter\ORM\NotLike::class,
'ismemberof' => Filter\ORM\IsMemberOf::class,
'orx' => Filter\ORM\OrX::class,
'andx' => Filter\ORM\AndX::class,
// 'innerjoin' => Filter\ORM\InnerJoin::class,
// 'leftjoin' => Filter\ORM\LeftJoin::class,
],
'factories' => [
Filter\ORM\Equals::class => InvokableFactory::class,
Filter\ORM\NotEquals::class => InvokableFactory::class,
Filter\ORM\LessThan::class => InvokableFactory::class,
Filter\ORM\LessThanOrEquals::class => InvokableFactory::class,
Filter\ORM\GreaterThan::class => InvokableFactory::class,
Filter\ORM\GreaterThanOrEquals::class => InvokableFactory::class,
Filter\ORM\IsNull::class => InvokableFactory::class,
Filter\ORM\IsNotNull::class => InvokableFactory::class,
Filter\ORM\In::class => InvokableFactory::class,
Filter\ORM\NotIn::class => InvokableFactory::class,
Filter\ORM\Between::class => InvokableFactory::class,
Filter\ORM\Like::class => InvokableFactory::class,
Filter\ORM\NotLike::class => InvokableFactory::class,
Filter\ORM\IsMemberOf::class => InvokableFactory::class,
Filter\ORM\OrX::class => InvokableFactory::class,
Filter\ORM\AndX::class => InvokableFactory::class,
// Filter\ORM\InnerJoin::class => InvokableFactory::class,
// Filter\ORM\LeftJoin::class => InvokableFactory::class,
],
],
'zf-doctrine-querybuilder-filter-odm' => [
'aliases' => [
'eq' => Filter\ODM\Equals::class,
'neq' => Filter\ODM\NotEquals::class,
'lt' => Filter\ODM\LessThan::class,
'lte' => Filter\ODM\LessThanOrEquals::class,
'gt' => Filter\ODM\GreaterThan::class,
'gte' => Filter\ODM\GreaterThanOrEquals::class,
'isnull' => Filter\ODM\IsNull::class,
'isnotnull' => Filter\ODM\IsNotNull::class,
'in' => Filter\ODM\In::class,
'notin' => Filter\ODM\NotIn::class,
'between' => Filter\ODM\Between::class,
'like' => Filter\ODM\Like::class,
'regex' => Filter\ODM\Regex::class,
],
'factories' => [
Filter\ODM\Equals::class => InvokableFactory::class,
Filter\ODM\NotEquals::class => InvokableFactory::class,
Filter\ODM\LessThan::class => InvokableFactory::class,
Filter\ODM\LessThanOrEquals::class => InvokableFactory::class,
Filter\ODM\GreaterThan::class => InvokableFactory::class,
Filter\ODM\GreaterThanOrEquals::class => InvokableFactory::class,
Filter\ODM\IsNull::class => InvokableFactory::class,
Filter\ODM\IsNotNull::class => InvokableFactory::class,
Filter\ODM\In::class => InvokableFactory::class,
Filter\ODM\NotIn::class => InvokableFactory::class,
Filter\ODM\Between::class => InvokableFactory::class,
Filter\ODM\Like::class => InvokableFactory::class,
Filter\ODM\Regex::class => InvokableFactory::class,
],
],
];
......@@ -31,7 +31,6 @@ return [
'Phpro\\DoctrineHydrationModule',
'ZF\\Apigility\\Doctrine\\Server',
'UnicaenOracle',
'ZF\Doctrine\QueryBuilder',
'Application',
'ImportData',
];
......@@ -8,6 +8,11 @@ puis lancez la commande git suivante pour "installer" la nouvelle version :
git fetch && git fetch --tags && git checkout 1.1.1
```
Ensuite, lancez la commande suivante pour mettre à niveau les bibliothèques PHP utilisées :
```bash
composer install
```
## Configuration PHP
Selon le moteur PHP que vous avez installé, l'emplacement du fichier de config PHP à créer/modifier diffère, exemple :
......
# v1.1.2
## Sources PHP
Sur le serveur, placez-vous dans le répertoire du web service (sans doute `/var/www/sygal-import-ws`)
puis lancez la commande git suivante pour "installer" la nouvelle version :
```bash
git fetch && git fetch --tags && git checkout 1.1.2
```
Ensuite, lancez la commande suivante pour mettre à niveau les bibliothèques PHP utilisées :
```bash
composer install
```
Selon le moteur PHP que vous avez installé, rechargez le service, exemple :
- php7.0-fpm : `service php7.0-fpm reload`
- apache2-mod-php7.0 : `service apache2 reload`
## Base de données
Néant.
......@@ -6,9 +6,25 @@
namespace Application;
use Doctrine\DBAL\Logging\EchoSQLLogger;
use Zend\ServiceManager\Factory\InvokableFactory;
return [
'doctrine' => [
'sql_logger_collector' => [
'orm_default' => [
'name' => 'orm_default',
'sql_logger' => 'echooooo',
],
],
],
'service_manager' => [
'invokables' => [
'echooooo' => EchoSQLLogger::class,
],
],
'router' => [
'routes' => [
'home' => [
......
<?php
use ImportData\V1\Query\Provider\FetchAll;
return [
'doctrine' => [
'driver' => [
......@@ -19,9 +22,11 @@ return [
],
'zf-apigility-doctrine-query-provider' => [
'aliases' => [
'default_orm' => \ImportData\V1\Query\Provider\FetchAll::class,
'acteur_fetch_all' => \ImportData\V1\Rest\Acteur\ActeurFetchAll::class,
],
'factories' => [
\ImportData\V1\Query\Provider\FetchAll::class => \Zend\ServiceManager\Factory\InvokableFactory::class,
\ImportData\V1\Rest\Acteur\ActeurFetchAll::class => \Zend\ServiceManager\Factory\InvokableFactory::class,
],
],
......
<?php
namespace ImportData\V1\Query\Provider;
use Doctrine\ORM\QueryBuilder;
use ZF\Apigility\Doctrine\Server\Query\Provider\DefaultOrm;
use ZF\Rest\ResourceEvent;
class FetchAll extends DefaultOrm
{
/**
* @param ResourceEvent $event
* @param string $entityClass
* @param array $parameters
* @return QueryBuilder
*/
public function createQuery(ResourceEvent $event, $entityClass, $parameters)
{
/** @var QueryBuilder $qb */
$qb = parent::createQuery($event, $entityClass, $parameters);
$qb->orderBy('row.id', 'asc'); // indispensable car les données sont fournies paginées
return $qb;
}
}
\ No newline at end of file
......@@ -2,12 +2,11 @@
namespace ImportData\V1\Rest\Acteur;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use ZF\Apigility\Doctrine\Server\Query\Provider\AbstractQueryProvider;
use ImportData\V1\Query\Provider\FetchAll;
use ZF\Rest\ResourceEvent;
class ActeurFetchAll extends AbstractQueryProvider
class ActeurFetchAll extends FetchAll
{
/**
* @param ResourceEvent $event
......@@ -17,14 +16,11 @@ class ActeurFetchAll extends AbstractQueryProvider
*/
public function createQuery(ResourceEvent $event, $entityClass, $parameters)
{
/** @var EntityRepository $repo */
$repo = $this->getObjectManager()->getRepository($entityClass);
$qb = $repo->createQueryBuilder('a');
$qb = parent::createQuery($event, $entityClass, $parameters);
if (isset($parameters['these_id'])) {
$qb
->andWhere('a.theseId = :theseId')
->andWhere('row.theseId = :theseId')
->setParameter('theseId', $parameters['these_id']);
}
......
......@@ -5,14 +5,4 @@ use ZF\Apigility\Doctrine\Server\Resource\DoctrineResource;
class ActeurResource extends DoctrineResource
{
public function fetchAll($data = [])
{
$data['order-by'] = [
'type' => 'field',
'field' => 'id',
'direction' => 'asc',
];
return parent::fetchAll($data);
}
}
......@@ -5,14 +5,4 @@ use ZF\Apigility\Doctrine\Server\Resource\DoctrineResource;
class DoctorantResource extends DoctrineResource
{
public function fetchAll($data = [])
{
$data['order-by'] = [
'type' => 'field',
'field' => 'id',
'direction' => 'asc',
];
return parent::fetchAll($data);
}
}
......@@ -5,14 +5,4 @@ use ZF\Apigility\Doctrine\Server\Resource\DoctrineResource;
class EcoleDoctoraleResource extends DoctrineResource
{
public function fetchAll($data = [])
{
$data['order-by'] = [
'type' => 'field',
'field' => 'id',
'direction' => 'asc',
];
return parent::fetchAll($data);
}
}
......@@ -5,14 +5,4 @@ use ZF\Apigility\Doctrine\Server\Resource\DoctrineResource;
class EtablissementResource extends DoctrineResource
{
public function fetchAll($data = [])
{
$data['order-by'] = [
'type' => 'field',
'field' => 'id',
'direction' => 'asc',
];
return parent::fetchAll($data);
}
}
......@@ -5,14 +5,4 @@ use ZF\Apigility\Doctrine\Server\Resource\DoctrineResource;
class IndividuResource extends DoctrineResource
{
public function fetchAll($data = [])
{
$data['order-by'] = [
'type' => 'field',
'field' => 'id',
'direction' => 'asc',
];
return parent::fetchAll($data);
}
}
......@@ -5,14 +5,4 @@ use ZF\Apigility\Doctrine\Server\Resource\DoctrineResource;
class RoleResource extends DoctrineResource
{
public function fetchAll($data = [])
{
$data['order-by'] = [