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.

101 linhas
3.6KB

  1. <?php
  2. namespace Lc\ShopBundle\Controller\Backend;
  3. use App\Entity\OrderShop;
  4. use App\Form\Backend\Common\AddressType;
  5. use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents;
  6. use FOS\UserBundle\Doctrine\UserManager;
  7. use FOS\UserBundle\Model\UserManagerInterface ;
  8. use Lc\ShopBundle\Context\AddressInterface;
  9. use Lc\ShopBundle\Model\Address;
  10. class UserController extends AdminController
  11. {
  12. public function showAction()
  13. {
  14. $id = $this->request->query->get('id');
  15. $easyadmin = $this->request->attributes->get('easyadmin');
  16. $entity = $easyadmin['item'];
  17. $this->orderShoprepo = $this->em->getRepository(OrderShop::class);
  18. /* dump($this->orderUtils->getRankTotalOrder($entity));
  19. die();
  20. dump($this->orderUtils->getRankSumOrderByUser($entity));
  21. dump($this->orderUtils->getRankTotalOrderByUser($entity));
  22. dump($this->orderUtils->getTotalSpentByUser($entity));
  23. dump($this->orderUtils->getAverageOrderByUser($entity));
  24. die();*/
  25. $this->dispatch(EasyAdminEvents::PRE_SHOW);
  26. $fields = $this->entity['show']['fields'];
  27. $deleteForm = $this->createDeleteForm($this->entity['name'], $id);
  28. $this->dispatch(EasyAdminEvents::POST_SHOW, [
  29. 'deleteForm' => $deleteForm,
  30. 'fields' => $fields,
  31. 'entity' => $entity,
  32. ]);
  33. $parameters = [
  34. 'entity' => $entity,
  35. 'fields' => $fields,
  36. 'delete_form' => $deleteForm->createView(),
  37. ];
  38. return $this->executeDynamicMethod('render<EntityName>Template', ['show', $this->entity['templates']['show'], $parameters]);
  39. }
  40. public function createNewEntity()
  41. {
  42. return $this->userManager->createUser();
  43. }
  44. public function persistEntity($user)
  45. {
  46. $this->userManager->updateUser($user, false);
  47. parent::persistEntity($user);
  48. }
  49. public function updateEntity($user)
  50. {
  51. $this->userManager->updateUser($user, false);
  52. parent::updateEntity($user);
  53. }
  54. public function removeEntity($user)
  55. {
  56. // désactivation UserMerchant
  57. if($user->getUserMerchants()) {
  58. $merchant = $this->merchantUtils->getMerchantCurrent() ;
  59. foreach($user->getUserMerchants() as $userMerchant) {
  60. if($userMerchant->getMerchant() == $merchant) {
  61. $userMerchant->setActive(false) ;
  62. $this->em->persist($userMerchant);
  63. $this->em->flush() ;
  64. $this->addFlash('success', 'Utilisateur supprimé du hub');
  65. }
  66. }
  67. }
  68. }
  69. protected function createUserListQueryBuilder($entityClass, $sortDirection, $sortField = null, $dqlFilter = null)
  70. {
  71. $queryBuilder = parent::createListQueryBuilder($entityClass, $sortDirection, $sortField, $dqlFilter) ;
  72. $queryBuilder->innerJoin('entity.userMerchants', 'um') ;
  73. $queryBuilder->andWhere('um.merchant = :merchant AND um.active = 1') ;
  74. $queryBuilder->setParameter('merchant', $this->merchantUtils->getMerchantCurrent()) ;
  75. return $queryBuilder ;
  76. }
  77. }