em = $em; $this->ldap = $ldap; } public function getSubscribedEvents(): array { return [ Events::postPersist, Events::preRemove, ]; } public function postPersist(LifecycleEventArgs $args): void { $this->entity = $args->getObject(); if (!$this->entity instanceof Entity) { return; } // Synchronisation nine2ldap $this->nine2ldap(); } public function preRemove(LifecycleEventArgs $args): void { $this->entity = $args->getObject(); if (!$this->entity instanceof Entity) { return; } // Synchronisation nine2ldap $this->nine2ldapremove(); } private function nine2ldap() { if ($this->ldap->isNine2Ldap()) { // On s'assure que la structure organisationnelle est présente $this->ldap->addOrganisations(); // Ajout / Modification dans annuaire $this->ldap->addUserGroup($this->entity); } } private function nine2ldapremove() { if ($this->ldap->isNine2Ldap()) { $this->ldap->delUserGroup($this->entity); } } }