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

Teste de l'interface Comparable

parent c319be34
Loading
Loading
Loading
Loading
+9 −0
Changes for module/Application/src/Application/Controller/AgentController.php: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -105,6 +105,15 @@ class AgentController extends AbstractActionController
            $agents = $this->getAgentService()->getAgentsWithFiltre($params);
        }

//        $jp = $this->getAgentService()->getAgent('8486');
//        $jl = $this->getAgentService()->getAgent('13209');
//        $tv = $this->getAgentService()->getAgent('16089');
//
//        $a = ($jp < $jl);
//        $b = ($jp < $tv);
//        $array = [$jp, $tv, $jl];
//        sort($array);

        return new ViewModel([
            'agents' => $agents,
            'params' => $params,
+12 −1
Changes for module/Application/src/Application/Entity/Db/Agent.php: 12 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Application\Entity\Db;

use Application\Provider\Etat\FichePosteEtats;
use Carriere\Entity\Db\NiveauEnveloppe;
use Doctrine\Common\Comparable;
use Element\Entity\Db\Interfaces\HasApplicationCollectionInterface;
use Element\Entity\Db\Interfaces\HasCompetenceCollectionInterface;
use Application\Entity\Db\Interfaces\HasComplementsInterface;
@@ -30,7 +31,8 @@ use Laminas\Permissions\Acl\Resource\ResourceInterface;
class Agent implements
    ResourceInterface,
    HasApplicationCollectionInterface, HasCompetenceCollectionInterface, HasFormationCollectionInterface,
    HasComplementsInterface
    HasComplementsInterface,
    Comparable
{
    use DbImportableAwareTrait;
    use AgentServiceAwareTrait;
@@ -218,6 +220,15 @@ class Agent implements
        return $this->getDenomination();
    }

    public function compareTo($other) : int
    {
        $aaa = $this->getNomUsuel(). '#' . $this->getPrenom() . "#" . $this->id;
        $bbb = $other->getNomUsuel(). '#' . $other->getPrenom() . "#" . $other->id;

        if ($aaa > $bbb) return 1;
        if ($aaa < $bbb) return -1;
        return 0;
    }
    /**
     * @return string|null
     */