MerchantResolver::class, 'section_resolver' => SectionResolver::class, ]); } public function __construct( SessionInterface $session, RequestStack $request, EntityManager $em, TranslatorAdmin $translatorAdmin, RolesDefinitionInterface $rolesDefinition, MerchantResolver $merchantResolver ) { parent::__construct($session, $request, $em, $translatorAdmin, $rolesDefinition); } public function configureCrud(Crud $crud): Crud { $crud->overrideTemplate('crud/new', '@LcCaracole/admin/user/user_new.html.twig'); return parent::configureCrud($crud); // TODO: Change the autogenerated stub } public function updateEntity(EntityManagerInterface $entityManager, $entityInstance): void { $this->updateUserMerchantRoles($entityManager, $entityInstance); parent::updateEntity($entityManager,$entityInstance); } /* public function persistEntity(EntityManagerInterface $entityManager, $entityInstance): void { $this->updateUserMerchantRoles($entityManager,$entityInstance); parent::updateEntity($entityManager,$entityInstance); }*/ protected function updateUserMerchantRoles($entityManager, UserInterface $user){ $userMerchant = $this->get('merchant_resolver')->getUserMerchant($user); if($userMerchant !== null){ $userMerchant->setRoles($user->getRoles()); //$entityManager->update($userMerchant); } } }