Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

UserAdminController.php 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. dump($sectionDefault);
  28. $url = $this->generateUrl($this->getParameter('lc_sov.homepage_route'), array('_switch_user' => $entity->getInstance()->getEmail(), 'section'=> $sectionDefault->getSlug()));
  29. $action->setLinkUrl($url);
  30. }
  31. }
  32. }
  33. }
  34. }