|
- <?php
-
- namespace Lc\CaracoleBundle\Controller\User;
-
- use Doctrine\ORM\EntityManagerInterface;
- use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
- use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField;
- use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
- use Lc\CaracoleBundle\Resolver\MerchantResolver;
- use Lc\CaracoleBundle\Resolver\SectionResolver;
- use Lc\SovBundle\Controller\AbstractAdminController;
- use Lc\SovBundle\Definition\RolesDefinition;
- use Lc\SovBundle\Definition\RolesDefinitionInterface;
- use Lc\SovBundle\Doctrine\EntityManager;
- use Lc\SovBundle\Model\User\UserInterface;
- use Lc\SovBundle\Translation\TranslatorAdmin;
- use Symfony\Component\Cache\Adapter\AdapterInterface;
- use Symfony\Component\HttpFoundation\RequestStack;
- use Symfony\Component\HttpFoundation\Session\SessionInterface;
- use Lc\SovBundle\Controller\User\UserAdminController as SovUserAdminController;
-
- abstract class UserAdminController extends SovUserAdminController
- {
- public static function getSubscribedServices()
- {
- return array_merge(parent::getSubscribedServices(), [
- 'merchant_resolver' => 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 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);
- }
- }
-
- }
|