Commit 5f4d40b0 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Le tiret dans un code de GTF ne pose plus problème

parent d83e4f3f
Loading
Loading
Loading
Loading
+39 −5
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@ use Application\Entity\Db\Etape;
 */
class NiveauEtape
{
    const SEPARATOR = '|';

    /**
     * @var Etape
     */
@@ -27,6 +29,8 @@ class NiveauEtape

    protected $pertinence;



    /**
     *
     * @param \Application\Entity\Db\Etape $etape
@@ -39,10 +43,13 @@ class NiveauEtape
        return $i;
    }



    /**
     *
     * @param string $lib
     * @param string $niv
     *
     * @return NiveauEtape
     */
    static public function getInstance($lib, $niv = null)
@@ -53,9 +60,12 @@ class NiveauEtape
        return $i;
    }



    /**
     *
     * @param \Traversable $etapes
     *
     * @return NiveauEtape[]
     */
    static public function getInstancesFromEtapes($etapes)
@@ -70,60 +80,84 @@ class NiveauEtape
        return $instances;
    }



    public function __toString()
    {
        return $this->getLib() . $this->getNiv();
    }



    public function getId()
    {
        return sprintf("%s-%s", $this->getLib(), $this->getNiv());
        return sprintf("%s%s%s", $this->getLib(), self::SEPARATOR, $this->getNiv());
    }



    public function getEtape()
    {
        return $this->etape;
    }



    public function getNiv()
    {
        return $this->niv;
    }



    public function getLib()
    {
        return $this->lib;
    }



    public function getPertinence()
    {
        return $this->pertinence;
    }



    public function setNiv($niv)
    {
        $this->niv = $niv;

        return $this;
    }



    public function setLib($lib)
    {
        $this->lib = $lib;

        return $this;
    }



    public function setPertinence($pertinence)
    {
        $this->pertinence = $pertinence;

        return $this;
    }



    public function setEtape(Etape $etape)
    {
        $this->etape      = $etape;
        $this->niv        = $this->etape->getNiveau();
        $this->lib        = $this->etape->getTypeFormation()->getGroupe()->getLibelleCourt();
        $this->pertinence = $this->etape->getTypeFormation()->getGroupe()->getPertinenceNiveau();

        return $this;
    }
}
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Application\Service;

use Application\Entity\Db\ElementTauxRegimes;
use Application\Entity\Db\Etape;
use Application\Entity\NiveauEtape;
use Application\Provider\Privilege\Privileges;
use Application\Service\Traits\CheminPedagogiqueServiceAwareTrait;
use Application\Service\Traits\ElementModulateurServiceAwareTrait;
@@ -103,7 +104,7 @@ class ElementPedagogiqueService extends AbstractEntityService
            if ($filters['niveau'] instanceof \Application\Entity\NiveauEtape) {
                $filters['niveau'] = $filters['niveau']->getId();
            }
            $niveau           = str_replace('-', '', $filters['niveau']);
            $niveau           = str_replace(NiveauEtape::SEPARATOR, '', $filters['niveau']);
            $whereContext[]   = 'CONCAT(gtf.libelle_court, e.niveau) = :niveau';
            $params['niveau'] = $niveau;
        }
+5 −3
Original line number Diff line number Diff line
@@ -14,14 +14,15 @@ class NiveauEtapeService extends AbstractService
    /**
     *
     * @param string $id
     *
     * @return \Application\Entity\NiveauEtape
     */
    public function get($id)
    {
        if (null === $id || 0 === $id || '-' === $id) {
        if (null === $id || 0 === $id || NiveauEtape::SEPARATOR === $id) {
            return null;
        }
        $tiretPos = strrpos($id, '-');
        $tiretPos = strrpos($id, NiveauEtape::SEPARATOR);

        $groupeTypeFormationLibelleCourt = (!$tiretPos) ? $id : substr($id, 0, $tiretPos);
        $niv                             = (!$tiretPos) ? false : substr($id, $tiretPos + 1);
@@ -30,6 +31,7 @@ class NiveauEtapeService extends AbstractService
        $niveau = new NiveauEtape();
        $niveau->setLib($groupeTypeFormationLibelleCourt);
        $niveau->setNiv($niv);

        return $niveau;
    }

+1 −1
Original line number Diff line number Diff line
@@ -311,7 +311,7 @@ class ServiceService extends AbstractEntityService
    public function finderByNiveauEtape(NiveauEtape $niveauEtape, QueryBuilder $qb = null, $alias = null)
    {
        [$qb, $alias] = $this->initQuery($qb, $alias);
        if ($niveauEtape && $niveauEtape->getId() !== '-') {
        if ($niveauEtape && $niveauEtape->getId() !== '|') {
            $serviceElement = $this->getServiceElementPedagogique();
            $serviceEtape   = $this->getServiceEtape();