Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

47 lines
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, string $pageName): 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->getSlug()));
  28. $action->setLinkUrl($url);
  29. }
  30. }
  31. }
  32. }
  33. }