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

fonction de recherche interne

parent e752c2f9
Loading
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -96,6 +96,13 @@ return [
                        UtilisateurPrivileges::UTILISATEUR_RECHERCHER,
                    ],
                ],
                [
                    'controller' => UtilisateurController::class,
                    'action' => [
                        'rechercher-interne',
                    ],
                    'roles' => [],
                ],
            ],
        ],
    ],
@@ -163,6 +170,16 @@ return [
                            ],
                        ],
                    ],
                    'rechercher-interne' => [
                        'type'          => Segment::class,
                        'options'       => [
                            'route'       => '/rechercher-interne',
                            'defaults'    => [
                                'controller' => UtilisateurController::class,
                                'action' => 'rechercher-interne',
                            ],
                        ],
                    ],
                    'rechercher-with-role' => [
                        'type'          => Segment::class,
                        'options'       => [
+18 −0
Original line number Diff line number Diff line
@@ -299,6 +299,24 @@ class UtilisateurController extends AbstractActionController
        return new JsonModel($result);
    }

    function rechercherInterneAction() : JsonModel
    {
        $term = $this->params()->fromQuery('term');
        $result = $this->getUserService()->findByTerm($term);

        $users = [];
        foreach ($result as $item) {
            $users[] = [
                'id' => $item->getId(),
                'label' => $item->getDisplayName(),
                'extra' => $item->getEmail(),
            ];
        }
        usort($users, function ($a, $b) { return strcmp($a['label'], $b['label']); });

        return new JsonModel($users);
    }

    public function rechercherWithRoleAction() : JsonModel
    {
        $term = $this->params()->fromQuery('term');