Commit 47b52f1a authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Nettoyage des services : categorie, corps, correspondance, grade

parent 7225c645
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -11,8 +11,6 @@ use Zend\Mvc\Controller\AbstractActionController;

class CategorieService
{
//    use UserServiceAwareTrait;
//    use EntityManagerAwareTrait;
    use GestionEntiteHistorisationTrait;

    /** GESTION DES ENTITES *******************************************************************************************/
@@ -129,7 +127,7 @@ class CategorieService
     * @param string $param
     * @return Categorie
     */
    public function getRequestedCategorie($controller, $param='categorie')
    public function getRequestedCategorie(AbstractActionController $controller, $param='categorie')
    {
        $id = $controller->params()->fromRoute($param);
        $result = $this->getCategorie($id);
@@ -140,7 +138,7 @@ class CategorieService
     * @param string $code
     * @return Categorie
     */
    public function getCategorieByCode($code)
    public function getCategorieByCode(string $code)
    {
        $qb = $this->createQueryBuider()
            ->andWhere('categorie.code = :code')
+2 −2
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ trait CategorieServiceAwareTrait {
    /**
     * @return CategorieService
     */
    public function getCategorieService()
    public function getCategorieService() : CategorieService
    {
        return $this->categorieService;
    }
@@ -19,7 +19,7 @@ trait CategorieServiceAwareTrait {
     * @param CategorieService $categorieService
     * @return CategorieService
     */
    public function setCategorieService($categorieService)
    public function setCategorieService(CategorieService $categorieService) : CategorieService
    {
        $this->categorieService = $categorieService;
        return $this->categorieService;
+2 −17
Original line number Diff line number Diff line
@@ -35,7 +35,8 @@ class CorpsService {
     * @return QueryBuilder
     */
    public function createQueryBuilder() {
        $qb = $this->getEntityManager()->getRepository(Corps::class)->createQueryBuilder('corps');
        $qb = $this->getEntityManager()->getRepository(Corps::class)->createQueryBuilder('corps')
        ;
        return $qb;
    }

@@ -58,21 +59,6 @@ class CorpsService {
            ;
        }


        $result = $qb->getQuery()->getResult();
        return $result;
    }

    /**
     * @param string $champ
     * @param string $ordre
     * @return Corps[]
     */
    public function getCorpsHistorises($champ = 'libelleLong', $ordre = 'ASC') {
        $qb = $this->createQueryBuilder()
            ->andWhere('corps.histo IS NOT NULL')
            ->orderBy('corps.' . $champ, $ordre)
        ;
        $result = $qb->getQuery()->getResult();
        return $result;
    }
@@ -116,5 +102,4 @@ class CorpsService {
        return $result;
    }


}
+2 −2
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ trait CorpsServiceAwareTrait {
    /**
     * @return CorpsService
     */
    public function getCorpsService()
    public function getCorpsService() : CorpsService
    {
        return $this->corpsService;
    }
@@ -19,7 +19,7 @@ trait CorpsServiceAwareTrait {
     * @param CorpsService $corpsService
     * @return CorpsService
     */
    public function setCorpsService($corpsService)
    public function setCorpsService(CorpsService $corpsService) : CorpsService
    {
        $this->corpsService = $corpsService;
        return $this->corpsService;
+8 −2
Original line number Diff line number Diff line
@@ -45,9 +45,15 @@ class CorrespondanceService {
        return $result;
    }

    public function getCorrespondancesAsOptions()
    /**
     * @param string $champ
     * @param string $ordre
     * @param bool $avecAgent
     * @return array
     */
    public function getCorrespondancesAsOptions(string $champ = 'categorie', string $ordre = 'ASC', bool $avecAgent=false)
    {
        $correspondances = $this->getCorrespondances();
        $correspondances = $this->getCorrespondances($champ, $ordre, $avecAgent);
        $options = [];
        foreach($correspondances as $correspondance) {
            $options[$correspondance->getId()] = $correspondance->getCategorie() . " - " . $correspondance->getLibelleLong();
Loading