|
- <?php
-
- namespace Lc\CaracoleBundle\Controller\User;
-
-
- use EasyCorp\Bundle\EasyAdminBundle\Collection\EntityCollection;
- use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
- use Lc\CaracoleBundle\Controller\ControllerTrait;
- use Lc\SovBundle\Container\User\UserContainer;
- use Lc\SovBundle\Controller\User\UserAdminController as SovUserAdminController;
- use Lc\SovBundle\Definition\ActionDefinition;
- use Lc\SovBundle\Model\User\UserInterface;
- use Lc\SovBundle\Repository\RepositoryQueryInterface;
-
- abstract class UserAdminController extends SovUserAdminController
- {
- use ControllerTrait;
-
- public function getRepositoryQuery(): RepositoryQueryInterface
- {
- return $this->container->get($this->getContainerFqcn())->getRepositoryQuery();
- }
-
- public function createEntity(string $entityFqcn)
- {
- return $this->getUserContainer()->getFactory()->create();
- }
-
- public function overrideEntitiesActions(?EntityCollection $entities, string $pageName): void
- {
- foreach ($entities as $entity) {
- foreach ($entity->getActions() as $action) {
- if ($action->getName() == ActionDefinition::SWITCH_USER) {
- $sectionDefault = $this->getSectionContainer()->getStore()->setMerchant($this->getMerchantCurrent())->getOneDefault();
-
- $url = $this->generateUrl($this->getParameter('lc_sov.homepage_route'), array('_switch_user' => $entity->getInstance()->getEmail(), 'section' => $sectionDefault->getSlug()));
- $action->setLinkUrl($url);
- }
- }
-
- }
- }
-
-
- public function getDeleteUserWarningMessageList(UserInterface $user): array
- {
- $warningMessages = parent::getDeleteUserWarningMessageList($user);
-
- foreach ($this->getUserMerchantContainer()->getStore()->getByUserOutOfContext($user) as $userMerchant) {
- if ($this->getUserMerchantContainer()->getSolver()->isCreditActive($userMerchant) && $userMerchant->getCredit() != 0) {
- $warningMessages['danger'][] = $this->getTranslatorAdmin()->transFlashMessage('error', 'deleteHasCredit', 'User', array('%merchant%' => $userMerchant->getMerchant()));
- }
- }
-
- foreach ($this->getReductionCatalogContainer()->getStore()->getByUserOutOfContext($user) as $reductionCatalog) {
- $warningMessages['danger'][] = $this->getTranslatorAdmin()->transFlashMessage(
- 'error',
- 'deleteHasReductionCatalog',
- 'User',
- array(
- '%merchant%' => $reductionCatalog->getMerchant(),
- '%id%' => $reductionCatalog->getId()
- )
- );
- }
-
- foreach ($this->getReductionCartContainer()->getStore()->getByUserOutOfContext($user) as $reductionCart) {
- $warningMessages['danger'][] = $this->getTranslatorAdmin()->transFlashMessage(
- 'error',
- 'deleteHasReductionCart',
- 'User',
- array(
- '%merchant%' => $reductionCart->getMerchant(),
- '%id%' => $reductionCart->getId()
- )
- );
- }
-
- foreach ($this->getReductionCreditContainer()->getStore()->getReductionCreditByUserOutOfContext($user) as $reductionCredit) {
- $warningMessages['warning'][] = $this->getTranslatorAdmin()->transFlashMessage(
- 'error',
- 'deleteHasReductionCredit',
- 'User',
- array(
- '%merchant%' => $reductionCredit->getMerchant(),
- '%id%' => $reductionCredit->getId()
- )
- );
- }
-
- foreach ($this->getReductionCreditContainer()->getStore()->getReductionGiftByUserOutOfContext($user) as $reductionGift) {
- $warningMessages['warning'][] = $this->getTranslatorAdmin()->transFlashMessage(
- 'error',
- 'deleteHasReductionGift',
- 'User',
- array(
- '%merchant%' => $reductionGift->getMerchant(),
- '%id%' => $reductionGift->getId()
- )
- );
- }
-
-
- return $warningMessages;
- }
-
-
- }
|