Commit 776d1e9b authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Préservation intervenant courant

parent 1fc27622
Loading
Loading
Loading
Loading
Loading
+11 −5
Changes for code/test3.php: 11 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -6,14 +6,20 @@
 * @var $io         \Symfony\Component\Console\Style\SymfonyStyle
 */

echo '<br /><br /><br /><br /><br /><br /><br />';

$um = $container->get(\Framework\User\UserManager::class);
$c = null;
dump($um->getCurrent());
dump($um->getCurrentProfile());

//$c = $um->getPrivileges();
$intervenant = $um->getCurrentProfile()->getContext('intervenant');

dump($intervenant->getId());

$ldap = $container->get(\Utilisateur\Connecteur\LdapConnecteur::class);

dump($ldap->getUtilisateurCourantCode());


$c = $um->getProfiles();

echo '<br /><br /><br /><br /><br /><br /><br />';
dump($c);
 No newline at end of file
+14 −1
Changes for module/Framework/src/User/UserManager.php: 14 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -2,8 +2,11 @@

namespace Framework\User;

use Framework\Application\Application;
use Framework\Application\Session;
use Intervenant\Service\IntervenantService;
use UnicaenAuthentification\Service\UserContext;
use Utilisateur\Connecteur\LdapConnecteur;

class UserManager
{
@@ -17,7 +20,8 @@ class UserManager

    public function __construct(
        private readonly Session        $session,
        private readonly UserContext $userContext
        private readonly UserContext    $userContext,
        private readonly LdapConnecteur $ldap,
    )
    {
    }
@@ -53,6 +57,15 @@ class UserManager

            $profile->setContext('role', $role->getDbRole());
            $profile->setContext('structure', $role->getStructure());
            if (!$role->getDbRole()) {
                $utilisateurCode = $this->ldap->getUtilisateurCourantCode();
                if ($utilisateurCode) {
                    $intervenantService = Application::getInstance()->container()->get(IntervenantService::class);
                    $intervenant = $intervenantService->getByUtilisateurCode($utilisateurCode);
                    $profile->setContext('intervenant', $intervenant);
                }
            }

            $profiles[$profile->getId()] = $profile;
        }

+8 −1
Changes for module/Intervenant/src/Entity/Db/Intervenant.php: 8 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -368,7 +368,14 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import

    function __sleep ()
    {
        return [];
        return [
            'id',
            'code',
            'codeRh',
            'utilisateurCode',
            'nomUsuel',
            'prenom',
        ];
    }