Skip to content

Commit

Permalink
Scope, coherence, and misc (found by stan)
Browse files Browse the repository at this point in the history
  • Loading branch information
prytoegrian committed May 24, 2018
1 parent 3d2cb5e commit f0c0f6e
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 20 deletions.
1 change: 0 additions & 1 deletion Absence/Type/TypeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ private function getOne(IResponse $response, int $id) : IResponse
* @param IResponse $response Réponse Http
*
* @return IResponse
* @throws \Exception en cas d'erreur inconnue (fallback, ne doit pas arriver)
*/
private function getList(IRequest $request, IResponse $response)
{
Expand Down
2 changes: 1 addition & 1 deletion Groupe/Employe/EmployeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getList(array $parametres) : array
{
$this->queryBuilder->select('users.*, users.u_login AS id');
$this->queryBuilder->innerJoin('current', 'conges_users', 'users', 'current.gu_login = u_login');
$this->setWhere($parametres);
$this->setWhere($this->getParamsConsumer2Storage($parametres));
$res = $this->queryBuilder->execute();

$data = $res->fetchAll(\PDO::FETCH_ASSOC);
Expand Down
2 changes: 1 addition & 1 deletion Groupe/GrandResponsable/GrandResponsableRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function getList(array $parametres) : array
{
$this->queryBuilder->select('users.*, users.u_login AS id');
$this->queryBuilder->innerJoin('current', 'conges_users', 'users', 'current.ggr_login = u_login');
$this->setWhere($parametres);
$this->setWhere($this->getParamsConsumer2Storage($parametres));
$res = $this->queryBuilder->execute();

$data = $res->fetchAll(\PDO::FETCH_ASSOC);
Expand Down
2 changes: 1 addition & 1 deletion Groupe/Responsable/ResponsableRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getList(array $parametres) : array
{
$this->queryBuilder->select('users.*, users.u_login AS id');
$this->queryBuilder->innerJoin('current', 'conges_users', 'users', 'current.gr_login = u_login');
$this->setWhere($parametres);
$this->setWhere($this->getParamsConsumer2Storage($parametres));
$res = $this->queryBuilder->execute();

$data = $res->fetchAll(\PDO::FETCH_ASSOC);
Expand Down
10 changes: 4 additions & 6 deletions Planning/Creneau/CreneauController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,21 @@ public function get(IRequest $request, IResponse $response, array $arguments) :
return $this->getList($response, (int) $arguments['planningId']);
}

return $this->getOne($response, (int) $arguments['creneauId'], (int) $arguments['planningId']);
return $this->getOne($response, (int) $arguments['creneauId']);
}

/**
* Retourne un élément unique
*
* @param IResponse $response Réponse Http
* @param int $id ID de l'élément
* @param int $planningId Contrainte de recherche sur le planning
*
* @return IResponse, 404 si l'élément n'est pas trouvé, 200 sinon
*/
private function getOne(IResponse $response, $id, $planningId)
private function getOne(IResponse $response, $id)
{
try {
$creneau = $this->repository->getOne($id, $planningId);
$creneau = $this->repository->getOne($id);
} catch (\DomainException $e) {
return $this->getResponseNotFound($response, 'Element « creneaux#' . $id . ' » is not a valid resource');
} catch (\Exception $e) {
Expand Down Expand Up @@ -159,9 +158,8 @@ public function put(IRequest $request, IResponse $response, array $arguments) :
}

$id = (int) $arguments['creneauId'];
$planningId = (int) $arguments['planningId'];
try {
$creneau = $this->repository->getOne($id, $planningId);
$creneau = $this->repository->getOne($id);
} catch (\DomainException $e) {
return $this->getResponseNotFound($response, 'Element « creneau#' . $id . ' » is not a valid resource');
} catch (\Exception $e) {
Expand Down
15 changes: 8 additions & 7 deletions Tools/Libraries/ARepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace LibertAPI\Tools\Libraries;

use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Query\QueryBuilder;

/**
* Garant de la cohérence métier de l'entité en relation.
Expand Down Expand Up @@ -31,7 +32,7 @@ public function __construct(Driver\Connection $storageConnector)
protected $storageConnector;

/**
* @var Query\QueryBuilder
* @var QueryBuilder
*/
protected $queryBuilder;

Expand All @@ -56,7 +57,7 @@ public function getOne(int $id) : AEntite

$entiteClass = $this->getEntiteClass();

return new $entiteClass($this->getStorage2Entite($data));
return new $entiteClass($this->getStorage2Entite($data));
}

/**
Expand All @@ -70,7 +71,7 @@ public function getOne(int $id) : AEntite
public function getList(array $parametres) : array
{
$this->queryBuilder->select('*');
$this->setWhere($parametres);
$this->setWhere($this->getParamsConsumer2Storage($parametres));
$res = $this->queryBuilder->execute();

$data = $res->fetchAll(\PDO::FETCH_ASSOC);
Expand Down Expand Up @@ -128,7 +129,7 @@ public function postOne(array $data, AEntite $entite) : int
$this->setValues($this->getEntite2Storage($entite));
$this->queryBuilder->execute();

return $this->storageConnector->lastInsertId();
return (int) $this->storageConnector->lastInsertId();
}

/**
Expand Down Expand Up @@ -194,23 +195,23 @@ abstract protected function getTableName() : string;
/**
* Initie une transaction
*/
private function beginTransaction() : bool
final protected function beginTransaction() : bool
{
return $this->storageConnector->beginTransaction();
}

/**
* Valide une transaction
*/
private function commit() : bool
final protected function commit() : bool
{
return $this->storageConnector->commit();
}

/**
* Annule une transaction
*/
private function rollback() : bool
final protected function rollback() : bool
{
return $this->storageConnector->rollBack();
}
Expand Down
3 changes: 2 additions & 1 deletion Tools/Middlewares/Identification.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public function __construct(IRequest $request, \LibertAPI\Tools\Libraries\ARepos
try {
$this->utilisateur = $repository->find([
'token' => $token,
'gt_date_last_access' => $this->getDateLastAccessAuthorized()
'gt_date_last_access' => $this->getDateLastAccessAuthorized(),
'isActif' => true,
]);
} catch (\UnexpectedValueException $e) {
return;
Expand Down
1 change: 0 additions & 1 deletion Utilisateur/UtilisateurEntite.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace LibertAPI\Utilisateur;

use LibertAPI\Tools\Exceptions\MissingArgumentException;

use LibertAPI\Tools\Helpers\Formatter;

/**
Expand Down
2 changes: 1 addition & 1 deletion Utilisateur/UtilisateurRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function find(array $parametres)
public function getList(array $parametres) : array
{
$this->queryBuilder->select('*, u_login AS id');
$this->setWhere($parametres);
$this->setWhere($this->getParamsConsumer2Storage($parametres));
$res = $this->queryBuilder->execute();
$data = $res->fetchAll(\PDO::FETCH_ASSOC);

Expand Down

0 comments on commit f0c0f6e

Please sign in to comment.