Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

46 linhas
1.5KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Controller\User;
  3. use EasyCorp\Bundle\EasyAdminBundle\Collection\EntityCollection;
  4. use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
  5. use Lc\CaracoleBundle\Controller\ControllerTrait;
  6. use Lc\SovBundle\Container\User\UserContainer;
  7. use Lc\SovBundle\Controller\User\UserAdminController as SovUserAdminController;
  8. use Lc\SovBundle\Definition\ActionDefinition;
  9. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  10. abstract class UserAdminController extends SovUserAdminController
  11. {
  12. use ControllerTrait;
  13. public function getRepositoryQuery(): RepositoryQueryInterface
  14. {
  15. return $this->getUserContainer()->getRepositoryQuery();
  16. }
  17. public function createEntity(string $entityFqcn)
  18. {
  19. return $this->getUserContainer()->getFactory()->create();
  20. }
  21. public function overrideEntitiesActions(?EntityCollection $entities): void
  22. {
  23. foreach ($entities as $entity) {
  24. foreach ($entity->getActions() as $action){
  25. if($action->getName() == ActionDefinition::SWITCH_USER){
  26. $sectionDefault = $this->getSectionContainer()->getStore()->setMerchant($this->getMerchantCurrent())->getOneDefault();
  27. $url = $this->generateUrl($this->getParameter('lc_sov.homepage_route'), array('_switch_user' => $entity->getInstance()->getEmail(), 'section'=> $sectionDefault));
  28. $action->setLinkUrl($url);
  29. }
  30. }
  31. }
  32. }
  33. }