Skip to content

Commit

Permalink
Suppression de la DAO (#42)
Browse files Browse the repository at this point in the history
* Added StorageConnector param in Repository

* Added table name in repo

* Added getById Repo

* Deleted all DAO TU files

* Deleted all Repo TU files

* Moved typeDao class into typeRepo class

* Moved UtilisateurDao class to UtilisateurRepo class

* Moved Groupe DAOs classes into Groupe Repos classes

* Moved JourFerieDao class into Jour FerieRepo class

* Moved JournalDao class into JournalRepo class

* Moved Planning DAOs classes into Planning Repo classes

* Well formed contracts for Repository

* Well formed contracts (2)

* All Repositories tested

* Repositories only do repositories stuff (populate action in controller)

* Description put UtilisateurRepo for Authentication

* Scope, coherence, and misc (found by stan)
  • Loading branch information
prytoegrian committed May 26, 2018
1 parent 9675a1f commit d07965c
Show file tree
Hide file tree
Showing 62 changed files with 1,427 additions and 3,794 deletions.
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -155,7 +154,8 @@ public function put(IRequest $request, IResponse $response, array $arguments) :
}

try {
$this->repository->putOne($body, $resource);
$resource->populate($body);
$this->repository->putOne($resource);
} catch (MissingArgumentException $e) {
return $this->getResponseMissingArgument($response);
} catch (\DomainException $e) {
Expand Down
187 changes: 0 additions & 187 deletions Absence/Type/TypeDao.php

This file was deleted.

85 changes: 78 additions & 7 deletions Absence/Type/TypeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@
*/
class TypeRepository extends \LibertAPI\Tools\Libraries\ARepository
{
final protected function getEntiteClass() : string
{
return TypeEntite::class;
}

/**
* {@inheritDoc}
*/
final protected function getParamsConsumer2Dao(array $paramsConsumer) : array
final protected function getParamsConsumer2Storage(array $paramsConsumer) : array
{
unset($paramsConsumer);
return [];
Expand All @@ -26,13 +31,79 @@ final protected function getParamsConsumer2Dao(array $paramsConsumer) : array
/**
* @inheritDoc
*/
public function deleteOne(AEntite $entite)
final protected function getStorage2Entite(array $dataStorage)
{
return [
'id' => $dataStorage['ta_id'],
'type' => $dataStorage['ta_type'],
'libelle' => $dataStorage['ta_libelle'],
'libelleCourt' => $dataStorage['ta_short_libelle'],
];
}

/**
* Définit les values à insérer
*
* @param array $values
*/
final protected function setValues(array $values)
{
try {
$this->dao->delete($entite->getId());
$entite->reset();
} catch (\Exception $e) {
throw $e;
$this->queryBuilder->setValue('ta_type', ':type');
$this->queryBuilder->setParameter(':type', $values['type']);
$this->queryBuilder->setValue('ta_libelle', ':libelle');
$this->queryBuilder->setParameter(':libelle', $values['libelle']);
$this->queryBuilder->setValue('ta_short_libelle', ':libelleCourt');
$this->queryBuilder->setParameter(':libelleCourt', $values['libelleCourt']);
}

final protected function setSet(array $parametres)
{
if (!empty($parametres['type'])) {
$this->queryBuilder->set('ta_type', ':type');
$this->queryBuilder->setParameter(':type', $parametres['type']);
}
if (!empty($parametres['libelle'])) {
$this->queryBuilder->set('ta_libelle', ':libelle');
// @TODO : changer le schema
$this->queryBuilder->setParameter(':libelle', $parametres['libelle']);
}
if (!empty($parametres['libelleCourt'])) {
$this->queryBuilder->set('ta_short_libelle', ':libelleCourt');
$this->queryBuilder->setParameter(':libelleCourt', $parametres['libelleCourt']);
}
}

/**
* @inheritDoc
*/
final protected function getEntite2Storage(AEntite $entite) : array
{
return [
'type' => $entite->getType(),
'libelle' => $entite->getLibelle(),
'libelleCourt' => $entite->getLibelleCourt(),
];
}

/**
* Définit les filtres à appliquer à la requête
*
* @param array $parametres
* @example [filter => []]
*/
final protected function setWhere(array $parametres)
{
if (!empty($parametres['id'])) {
$this->queryBuilder->andWhere('ta_id = :id');
$this->queryBuilder->setParameter(':id', (int) $parametres['id']);
}
}

/**
* @inheritDoc
*/
final protected function getTableName() : string
{
return 'conges_type_absence';
}
}
Loading

0 comments on commit d07965c

Please sign in to comment.