namespace Lc\CaracoleBundle\Controller\Order; | namespace Lc\CaracoleBundle\Controller\Order; | ||||
use Lc\CaracoleBundle\Container\Order\OrderStatusContainer; | use Lc\CaracoleBundle\Container\Order\OrderStatusContainer; | ||||
use Lc\CaracoleBundle\Controller\AbstractAdminController; | use Lc\CaracoleBundle\Controller\AbstractAdminController; | ||||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | use Lc\CaracoleBundle\Controller\AdminControllerTrait; | ||||
{ | { | ||||
return $this->get(OrderStatusContainer::class)->getRepositoryQuery(); | return $this->get(OrderStatusContainer::class)->getRepositoryQuery(); | ||||
} | } | ||||
public function createEntity(string $entityFqcn) | |||||
{ | |||||
return $this->getOrderStatusContainer()->getFactory()->create(); | |||||
} | |||||
} | } |
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; | use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; | ||||
use Lc\CaracoleBundle\Container\Product\ProductCategoryContainer; | |||||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||||
use Lc\SovBundle\Controller\AbstractAdminController; | |||||
use Lc\CaracoleBundle\Controller\AbstractAdminController; | |||||
use Lc\SovBundle\Field\CKEditorField; | use Lc\SovBundle\Field\CKEditorField; | ||||
use Lc\SovBundle\Field\StatusField; | use Lc\SovBundle\Field\StatusField; | ||||
use Lc\SovBundle\Field\ToggleField; | use Lc\SovBundle\Field\ToggleField; | ||||
abstract class ProductCategoryAdminController extends AbstractAdminController | abstract class ProductCategoryAdminController extends AbstractAdminController | ||||
{ | { | ||||
use AdminControllerTrait; | |||||
public function getRepositoryQuery() :RepositoryQueryInterface | public function getRepositoryQuery() :RepositoryQueryInterface | ||||
{ | { | ||||
return $this->get(ProductCategoryContainer::class)->getRepositoryQuery(); | |||||
return $this->getProductCategoryContainer()->getRepositoryQuery(); | |||||
} | |||||
public function createEntity(string $entityFqcn) | |||||
{ | |||||
return $this->getProductCategoryContainer()->getFactory()->create($this->getSectionCurrent()); | |||||
} | } | ||||
public function configureFields(string $pageName): iterable | public function configureFields(string $pageName): iterable |
namespace Lc\CaracoleBundle\Controller\Product; | namespace Lc\CaracoleBundle\Controller\Product; | ||||
use Doctrine\ORM\QueryBuilder; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; | use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; | use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||||
use Lc\CaracoleBundle\Container\Order\OrderShopContainer; | use Lc\CaracoleBundle\Container\Order\OrderShopContainer; | ||||
use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer; | use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer; | ||||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | |||||
use Lc\CaracoleBundle\Field\Address\AddressField; | |||||
use Lc\CaracoleBundle\Controller\AbstractAdminController; | |||||
use Lc\CaracoleBundle\Resolver\SectionResolver; | use Lc\CaracoleBundle\Resolver\SectionResolver; | ||||
use Lc\SovBundle\Controller\AbstractAdminController; | |||||
use Lc\SovBundle\Field\BooleanField; | |||||
use Lc\SovBundle\Field\CKEditorField; | |||||
use Lc\SovBundle\Field\StatusField; | |||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
use Symfony\Component\HttpFoundation\RequestStack; | |||||
use Symfony\Component\HttpFoundation\Response; | use Symfony\Component\HttpFoundation\Response; | ||||
abstract class ProductFamilyAdminController extends AbstractAdminController | abstract class ProductFamilyAdminController extends AbstractAdminController | ||||
{ | { | ||||
use AdminControllerTrait; | |||||
public function getRepositoryQuery() :RepositoryQueryInterface | public function getRepositoryQuery() :RepositoryQueryInterface | ||||
{ | { | ||||
return $this->get(ProductFamilyContainer::class)->getRepositoryQuery(); | return $this->get(ProductFamilyContainer::class)->getRepositoryQuery(); | ||||
} | } | ||||
public function createEntity(string $entityFqcn) | |||||
{ | |||||
return $this->getProductFamilyContainer() | |||||
->getFactory() | |||||
->create($this->getMerchantCurrent()); | |||||
} | |||||
// public function createIndexQueryBuilder(SearchDto $searchDto, EntityDto $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder | // public function createIndexQueryBuilder(SearchDto $searchDto, EntityDto $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder | ||||
// { | // { | ||||
// $queryBuilder = parent::createIndexQueryBuilder($searchDto, $entityDto, $fields, $filters); | // $queryBuilder = parent::createIndexQueryBuilder($searchDto, $entityDto, $fields, $filters); |
namespace Lc\CaracoleBundle\Controller\Reduction; | namespace Lc\CaracoleBundle\Controller\Reduction; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||||
use Lc\CaracoleBundle\Container\Reduction\ReductionCartContainer; | use Lc\CaracoleBundle\Container\Reduction\ReductionCartContainer; | ||||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||||
use Lc\CaracoleBundle\Model\Config\TaxRateModel; | |||||
use Lc\CaracoleBundle\Model\Config\UnitModel; | |||||
use Lc\SovBundle\Controller\AbstractAdminController; | |||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
use Lc\CaracoleBundle\Controller\AbstractAdminController; | |||||
abstract class ReductionCartAdminController extends AbstractAdminController | abstract class ReductionCartAdminController extends AbstractAdminController | ||||
{ | { | ||||
use AdminControllerTrait; | |||||
public function getRepositoryQuery() :RepositoryQueryInterface | public function getRepositoryQuery() :RepositoryQueryInterface | ||||
{ | { | ||||
return $this->get(ReductionCartContainer::class)->getRepositoryQuery(); | |||||
return $this->getReductionCartContainer()->getRepositoryQuery(); | |||||
} | |||||
public function createEntity(string $entityFqcn) | |||||
{ | |||||
return $this->getReductionCartContainer()->getFactory()->create($this->getSectionCurrent()); | |||||
} | } | ||||
} | } |
namespace Lc\CaracoleBundle\Controller\Reduction; | namespace Lc\CaracoleBundle\Controller\Reduction; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||||
use Lc\CaracoleBundle\Container\Reduction\ReductionCatalogContainer; | |||||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||||
use Lc\CaracoleBundle\Model\Config\TaxRateModel; | |||||
use Lc\CaracoleBundle\Model\Config\UnitModel; | |||||
use Lc\SovBundle\Controller\AbstractAdminController; | |||||
use Lc\CaracoleBundle\Controller\AbstractAdminController; | |||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
abstract class ReductionCatalogAdminController extends AbstractAdminController | abstract class ReductionCatalogAdminController extends AbstractAdminController | ||||
{ | { | ||||
use AdminControllerTrait; | |||||
public function getRepositoryQuery() :RepositoryQueryInterface | |||||
public function getRepositoryQuery(): RepositoryQueryInterface | |||||
{ | { | ||||
return $this->get(ReductionCatalogContainer::class)->getRepositoryQuery(); | |||||
return $this->getReductionCatalogContainer()->getRepositoryQuery(); | |||||
} | } | ||||
public function createEntity(string $entityFqcn) | |||||
{ | |||||
return $this->getReductionCatalogContainer()->getFactory()->create($this->getSectionCurrent()); | |||||
} | |||||
} | } |
namespace Lc\CaracoleBundle\Controller\Reduction; | namespace Lc\CaracoleBundle\Controller\Reduction; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||||
use Lc\CaracoleBundle\Container\Reduction\ReductionCreditContainer; | use Lc\CaracoleBundle\Container\Reduction\ReductionCreditContainer; | ||||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||||
use Lc\CaracoleBundle\Model\Config\TaxRateModel; | |||||
use Lc\CaracoleBundle\Model\Config\UnitModel; | |||||
use Lc\SovBundle\Controller\AbstractAdminController; | |||||
use Lc\CaracoleBundle\Controller\AbstractAdminController; | |||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
abstract class ReductionCreditAdminController extends AbstractAdminController | abstract class ReductionCreditAdminController extends AbstractAdminController | ||||
{ | { | ||||
use AdminControllerTrait; | |||||
public function getRepositoryQuery() :RepositoryQueryInterface | public function getRepositoryQuery() :RepositoryQueryInterface | ||||
{ | { | ||||
return $this->get(ReductionCreditContainer::class)->getRepositoryQuery(); | return $this->get(ReductionCreditContainer::class)->getRepositoryQuery(); | ||||
} | } | ||||
public function createEntity(string $entityFqcn) | |||||
{ | |||||
return $this->getReductionCreditContainer()->getFactory()->create($this->getSectionCurrent()); | |||||
} | |||||
} | } |
public function createEntity(string $entityFqcn) | public function createEntity(string $entityFqcn) | ||||
{ | { | ||||
return $this->get(OpeningContainer::class) | |||||
return $this->getOpeningContainer() | |||||
->getFactory() | ->getFactory() | ||||
->create($this->get(SectionResolver::class)->getCurrent()); | |||||
->create($this->getSectionCurrent()); | |||||
} | } | ||||
} | } |
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||||
use Lc\CaracoleBundle\Container\Section\SectionContainer; | use Lc\CaracoleBundle\Container\Section\SectionContainer; | ||||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||||
use Lc\CaracoleBundle\Factory\Section\SectionFactory; | |||||
use Lc\CaracoleBundle\Form\Section\OpeningsFormType; | |||||
use Lc\CaracoleBundle\Controller\AbstractAdminController; | |||||
use Lc\CaracoleBundle\Model\Section\SectionModel; | use Lc\CaracoleBundle\Model\Section\SectionModel; | ||||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | use Lc\CaracoleBundle\Resolver\MerchantResolver; | ||||
use Lc\SovBundle\Controller\AbstractAdminController; | |||||
use Lc\SovBundle\Field\BooleanField; | use Lc\SovBundle\Field\BooleanField; | ||||
use Lc\SovBundle\Field\CKEditorField; | use Lc\SovBundle\Field\CKEditorField; | ||||
use Lc\SovBundle\Field\StatusField; | use Lc\SovBundle\Field\StatusField; | ||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
use Symfony\Component\HttpFoundation\Request; | |||||
use Symfony\Component\HttpFoundation\Session\SessionFactory; | |||||
use Symfony\Component\Routing\Annotation\Route; | |||||
abstract class SectionAdminController extends AbstractAdminController | abstract class SectionAdminController extends AbstractAdminController | ||||
{ | { | ||||
use AdminControllerTrait; | |||||
public function getRepositoryQuery() :RepositoryQueryInterface | public function getRepositoryQuery() :RepositoryQueryInterface | ||||
{ | { | ||||
return $this->get(SectionContainer::class)->getRepositoryQuery(); | return $this->get(SectionContainer::class)->getRepositoryQuery(); | ||||
} | } | ||||
public function createEntity(string $entityFqcn) | |||||
{ | |||||
return $this->getSectionContainer() | |||||
->getFactory() | |||||
->create($this->getMerchantCurrent()); | |||||
} | |||||
public function configureFields(string $pageName): iterable | public function configureFields(string $pageName): iterable | ||||
{ | { | ||||
return array_merge( | return array_merge( | ||||
); | ); | ||||
} | } | ||||
public function createEntity(string $entityFqcn) | |||||
{ | |||||
return $this->get(SectionContainer::class) | |||||
->getFactory() | |||||
->create($this->get(MerchantResolver::class)->getCurrent()); | |||||
} | |||||
} | } |
namespace Lc\CaracoleBundle\Controller\Site; | namespace Lc\CaracoleBundle\Controller\Site; | ||||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||||
use Lc\SovBundle\Container\Site\NewsContainer; | |||||
use Lc\CaracoleBundle\Controller\ControllerTrait; | |||||
use Lc\SovBundle\Controller\Site\NewsAdminController as SovNewsAdminController; | use Lc\SovBundle\Controller\Site\NewsAdminController as SovNewsAdminController; | ||||
abstract class NewsAdminController extends SovNewsAdminController | abstract class NewsAdminController extends SovNewsAdminController | ||||
{ | { | ||||
use AdminControllerTrait; | |||||
use ControllerTrait; | |||||
public function createEntity(string $entityFqcn) | public function createEntity(string $entityFqcn) | ||||
{ | { | ||||
return $this->get(NewsContainer::class) | |||||
return $this->getNewsContainer() | |||||
->getFactory() | ->getFactory() | ||||
->setSection($this->get(SectionResolver::class)->getCurrent()) | |||||
->setSection($this->getSectionCurrent()) | |||||
->create(); | ->create(); | ||||
} | } | ||||
} | } |
namespace Lc\CaracoleBundle\Controller\Site; | namespace Lc\CaracoleBundle\Controller\Site; | ||||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||||
use Lc\CaracoleBundle\Factory\Site\PageFactory; | |||||
use Lc\CaracoleBundle\Controller\ControllerTrait; | |||||
use Lc\CaracoleBundle\Resolver\SectionResolver; | use Lc\CaracoleBundle\Resolver\SectionResolver; | ||||
use Lc\SovBundle\Container\Site\PageContainer; | |||||
use Lc\SovBundle\Controller\Site\PageAdminController as SovPageAdminController; | use Lc\SovBundle\Controller\Site\PageAdminController as SovPageAdminController; | ||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||||
abstract class PageAdminController extends SovPageAdminController | abstract class PageAdminController extends SovPageAdminController | ||||
{ | { | ||||
use AdminControllerTrait; | |||||
use ControllerTrait; | |||||
public function createEntity(string $entityFqcn) | public function createEntity(string $entityFqcn) | ||||
{ | { | ||||
return $this->getPageContainer() | return $this->getPageContainer() | ||||
->getFactory() | ->getFactory() | ||||
->setSection($this->get(SectionResolver::class)->getCurrent()) | |||||
->setSection($this->getSectionCurrent()) | |||||
->create(); | ->create(); | ||||
} | } | ||||
} | } |
namespace Lc\CaracoleBundle\Controller\Ticket; | namespace Lc\CaracoleBundle\Controller\Ticket; | ||||
use App\Entity\Ticket\Ticket; | |||||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||||
use Lc\SovBundle\Container\Ticket\TicketContainer; | |||||
use Lc\CaracoleBundle\Controller\ControllerTrait; | |||||
use Lc\SovBundle\Controller\Ticket\TicketAdminController as SovTicketAdminController; | use Lc\SovBundle\Controller\Ticket\TicketAdminController as SovTicketAdminController; | ||||
use Lc\CaracoleBundle\Factory\Ticket\TicketFactory; | |||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||||
abstract class TicketAdminController extends SovTicketAdminController | abstract class TicketAdminController extends SovTicketAdminController | ||||
{ | { | ||||
use AdminControllerTrait; | |||||
use ControllerTrait; | |||||
public function createEntity(string $entityFqcn) | public function createEntity(string $entityFqcn) | ||||
{ | { | ||||
return $this->get(TicketContainer::class) | |||||
return $this->getTicketContainer() | |||||
->getFactory() | ->getFactory() | ||||
->setMerchant($this->get(MerchantResolver::class)->getCurrent()) | |||||
->setSection($this->getSectionCurrent()) | |||||
->create(); | ->create(); | ||||
} | } | ||||
} | } |
namespace Lc\CaracoleBundle\Controller\User; | namespace Lc\CaracoleBundle\Controller\User; | ||||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||||
use Lc\CaracoleBundle\Factory\User\GroupUserFactory; | |||||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||||
use Lc\SovBundle\Container\User\GroupUserContainer; | |||||
use Lc\CaracoleBundle\Controller\ControllerTrait; | |||||
use Lc\SovBundle\Controller\User\GroupUserAdminController as SovGroupUserAdminController; | use Lc\SovBundle\Controller\User\GroupUserAdminController as SovGroupUserAdminController; | ||||
abstract class GroupUserAdminController extends SovGroupUserAdminController | abstract class GroupUserAdminController extends SovGroupUserAdminController | ||||
{ | { | ||||
use AdminControllerTrait; | |||||
use ControllerTrait; | |||||
public function createEntity(string $entityFqcn) | public function createEntity(string $entityFqcn) | ||||
{ | { | ||||
return $this->get(GroupUserContainer::class) | |||||
return $this->getGroupUserContainer() | |||||
->getFactory() | ->getFactory() | ||||
->setMerchant($this->get(MerchantResolver::class)->getCurrent()) | |||||
->setMerchant($this->getMerchantCurrent()) | |||||
->create(); | ->create(); | ||||
} | } | ||||
} | } |
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Collection\EntityCollection; | use EasyCorp\Bundle\EasyAdminBundle\Collection\EntityCollection; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Action; | use EasyCorp\Bundle\EasyAdminBundle\Config\Action; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; | use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; | use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; | use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Event\AfterCrudActionEvent; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeCrudActionEvent; | use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeCrudActionEvent; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Exception\ForbiddenActionException; | use EasyCorp\Bundle\EasyAdminBundle\Exception\ForbiddenActionException; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Exception\InsufficientEntityPermissionException; | use EasyCorp\Bundle\EasyAdminBundle\Exception\InsufficientEntityPermissionException; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField; | use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; | use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; | use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; | ||||
use Lc\CaracoleBundle\Container\User\UserMerchantContainer; | use Lc\CaracoleBundle\Container\User\UserMerchantContainer; | ||||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||||
use Lc\CaracoleBundle\Controller\ControllerTrait; | |||||
use Lc\CaracoleBundle\Definition\ActionDefinition; | use Lc\CaracoleBundle\Definition\ActionDefinition; | ||||
use Lc\CaracoleBundle\Factory\User\UserFactory; | use Lc\CaracoleBundle\Factory\User\UserFactory; | ||||
use Lc\CaracoleBundle\Factory\User\UserMerchantFactory; | |||||
use Lc\CaracoleBundle\Form\Credit\CreditHistoryFormType; | use Lc\CaracoleBundle\Form\Credit\CreditHistoryFormType; | ||||
use Lc\CaracoleBundle\Form\User\UserMerchantFormType; | use Lc\CaracoleBundle\Form\User\UserMerchantFormType; | ||||
use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface; | use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface; | ||||
use Lc\SovBundle\Container\User\UserContainer; | use Lc\SovBundle\Container\User\UserContainer; | ||||
use Lc\SovBundle\Controller\AbstractAdminController; | use Lc\SovBundle\Controller\AbstractAdminController; | ||||
use Lc\SovBundle\Field\BooleanField; | use Lc\SovBundle\Field\BooleanField; | ||||
use Lc\SovBundle\Field\ToggleField; | |||||
use Lc\SovBundle\Model\User\UserInterface; | |||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | use Lc\SovBundle\Translation\TranslatorAdmin; | ||||
use Symfony\Component\HttpFoundation\Response; | use Symfony\Component\HttpFoundation\Response; | ||||
abstract class UserMerchantAdminController extends AbstractAdminController | abstract class UserMerchantAdminController extends AbstractAdminController | ||||
{ | { | ||||
use AdminControllerTrait; | |||||
use ControllerTrait; | |||||
public function getRepositoryQuery(): RepositoryQueryInterface | |||||
{ | |||||
return $this->getUserMerchantContainer()->getRepositoryQuery(); | |||||
} | |||||
public function getRepositoryQuery() :RepositoryQueryInterface | |||||
public function createEntity(string $entityFqcn) | |||||
{ | { | ||||
return $this->get(UserMerchantContainer::class)->getRepositoryQuery(); | |||||
return $this->getUserMerchantContainer()->getFactory()->createBase($this->getMerchantCurrent()); | |||||
} | } | ||||
public function overrideEntitiesActions(?EntityCollection $entities): void | public function overrideEntitiesActions(?EntityCollection $entities): void | ||||
{ | { | ||||
$context = $this->get(AdminContextProvider::class)->getContext(); | $context = $this->get(AdminContextProvider::class)->getContext(); | ||||
$adminUrlGenerator = $this->get(AdminUrlGenerator::class); | $adminUrlGenerator = $this->get(AdminUrlGenerator::class); | ||||
$creditControllerFqcn = $context->getCrudControllers()->findCrudFqcnByEntityFqcn( | $creditControllerFqcn = $context->getCrudControllers()->findCrudFqcnByEntityFqcn( | ||||
$this->get(EntityManagerInterface::class)->getEntityName(CreditHistoryInterface::class) | |||||
$this->get(EntityManagerInterface::class)->getEntityName(CreditHistoryInterface::class) | |||||
); | ); | ||||
if ($entities) { | if ($entities) { | ||||
foreach ($entity->getActions() as $action) { | foreach ($entity->getActions() as $action) { | ||||
if ($action->getName() == 'credit_history') { | if ($action->getName() == 'credit_history') { | ||||
$url = $adminUrlGenerator | $url = $adminUrlGenerator | ||||
->setController($creditControllerFqcn) | |||||
->set('userMerchantId', $entity->getInstance()->getId()) | |||||
->generateUrl(); | |||||
->setController($creditControllerFqcn) | |||||
->set('userMerchantId', $entity->getInstance()->getId()) | |||||
->generateUrl(); | |||||
$action->setLinkUrl($url); | $action->setLinkUrl($url); | ||||
} | } | ||||
} | } | ||||
$actions = parent::configureActions($actions); | $actions = parent::configureActions($actions); | ||||
$creditAction = Action::new('credit_history', false, 'fa fa-cash-register') | $creditAction = Action::new('credit_history', false, 'fa fa-cash-register') | ||||
->linkToCrudAction('credit_history') | |||||
->setHtmlAttributes( | |||||
array( | |||||
'data-toggle' => 'tooltip', | |||||
'title' => $this->get(TranslatorAdmin::class)->transAction('credit'), | |||||
->linkToCrudAction('credit_history') | |||||
->setHtmlAttributes( | |||||
array( | |||||
'data-toggle' => 'tooltip', | |||||
'title' => $this->get(TranslatorAdmin::class)->transAction('credit'), | |||||
) | |||||
) | ) | ||||
) | |||||
->setCssClass('btn btn-sm btn-success'); | |||||
->setCssClass('btn btn-sm btn-success'); | |||||
$actions->add(Crud::PAGE_INDEX, $creditAction); | $actions->add(Crud::PAGE_INDEX, $creditAction); | ||||
return $actions; | return $actions; | ||||
public function configureFields(string $pageName): iterable | public function configureFields(string $pageName): iterable | ||||
{ | { | ||||
$fields = [ | $fields = [ | ||||
IntegerField::new('id')->onlyOnIndex()->setSortable(true), | |||||
TextField::new('user.lastname')->setSortable(true), | |||||
TextField::new('user.firstname')->setSortable(true), | |||||
TextField::new('user.email')->setSortable(true), | |||||
BooleanField::new('active')->setSortable(true), | |||||
BooleanField::new('creditActive')->hideOnIndex(), | |||||
AssociationField::new('user'), | |||||
IntegerField::new('id')->onlyOnIndex()->setSortable(true), | |||||
TextField::new('user.lastname')->setSortable(true), | |||||
TextField::new('user.firstname')->setSortable(true), | |||||
TextField::new('user.email')->setSortable(true), | |||||
BooleanField::new('active')->setSortable(true), | |||||
BooleanField::new('creditActive')->hideOnIndex(), | |||||
AssociationField::new('user'), | |||||
]; | ]; | ||||
if ($this->isGranted('ROLE_SUPER_ADMIN')) { | if ($this->isGranted('ROLE_SUPER_ADMIN')) { | ||||
public function configureFilters(Filters $filters): Filters | public function configureFilters(Filters $filters): Filters | ||||
{ | { | ||||
return $filters | return $filters | ||||
->add(BooleanFilter::new('active')); | |||||
->add(BooleanFilter::new('active')); | |||||
} | } | ||||
public function new(AdminContext $context): Response | public function new(AdminContext $context): Response | ||||
$merchantResolver = $this->get(MerchantResolver::class); | $merchantResolver = $this->get(MerchantResolver::class); | ||||
$userMerchant = $this->get(UserMerchantContainer::class) | $userMerchant = $this->get(UserMerchantContainer::class) | ||||
->getFactory() | |||||
->create($merchantResolver->getCurrent()); | |||||
->getFactory() | |||||
->create($merchantResolver->getCurrent()); | |||||
$form = $this->createForm(UserMerchantFormType::class, $userMerchant); | $form = $this->createForm(UserMerchantFormType::class, $userMerchant); | ||||
$userMerchant->setUser($user); | $userMerchant->setUser($user); | ||||
$entityManager->create($userMerchant); | $entityManager->create($userMerchant); | ||||
$entityManager->flush(); | $entityManager->flush(); | ||||
$this->addFlashTranslator('success','created'); | |||||
$this->addFlashTranslator('success', 'created'); | |||||
$url = $this->get(AdminUrlGenerator::class)->setAction(ActionDefinition::INDEX)->generateUrl(); | $url = $this->get(AdminUrlGenerator::class)->setAction(ActionDefinition::INDEX)->generateUrl(); | ||||
return $this->redirect($url); | return $this->redirect($url); | ||||
return $this->redirect($url); | return $this->redirect($url); | ||||
} else { | } else { | ||||
$this->addFlashTranslator('error','already_exist'); | |||||
$this->addFlashTranslator('error', 'already_exist'); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
return $this->render( | return $this->render( | ||||
'@LcCaracole/admin/user/new_usermerchant.html.twig', | |||||
[ | |||||
'form' => $form->createView(), | |||||
] | |||||
'@LcCaracole/admin/user/new_usermerchant.html.twig', | |||||
[ | |||||
'form' => $form->createView(), | |||||
] | |||||
); | ); | ||||
} | } | ||||
} | } | ||||
return $this->render( | return $this->render( | ||||
'@LcCaracole/admin/user/edit_usermerchant.html.twig', | |||||
[ | |||||
'form' => $form->createView(), | |||||
] | |||||
'@LcCaracole/admin/user/edit_usermerchant.html.twig', | |||||
[ | |||||
'form' => $form->createView(), | |||||
] | |||||
); | ); | ||||
} | } | ||||
} | } | ||||
if (!$this->isGranted( | if (!$this->isGranted( | ||||
Permission::EA_EXECUTE_ACTION, | |||||
['action' => ActionDefinition::DETAIL, 'entity' => $context->getEntity()] | |||||
Permission::EA_EXECUTE_ACTION, | |||||
['action' => ActionDefinition::DETAIL, 'entity' => $context->getEntity()] | |||||
)) { | )) { | ||||
throw new ForbiddenActionException($context); | throw new ForbiddenActionException($context); | ||||
} | } | ||||
} | } | ||||
$options['action'] = $adminUrlGenerator | $options['action'] = $adminUrlGenerator | ||||
->setController($context->getCrud()->getControllerFqcn()) | |||||
->setAction('add_credit') | |||||
->setEntityId($context->getEntity()->getInstance()->getId()) | |||||
->set('userMerchant', 'niche') | |||||
->generateUrl(); | |||||
->setController($context->getCrud()->getControllerFqcn()) | |||||
->setAction('add_credit') | |||||
->setEntityId($context->getEntity()->getInstance()->getId()) | |||||
->set('userMerchant', 'niche') | |||||
->generateUrl(); | |||||
$addCreditHistoryForm = $this->createForm(CreditHistoryFormType::class, null, $options)->createView(); | $addCreditHistoryForm = $this->createForm(CreditHistoryFormType::class, null, $options)->createView(); | ||||
return $this->render( | return $this->render( | ||||
'@LcCaracole/admin/credit/credit_detail.html.twig', | |||||
[ | |||||
'pageName' => Crud::PAGE_DETAIL, | |||||
'entity' => $context->getEntity(), | |||||
'batch_actions' => array(), | |||||
'entities' => array(), | |||||
'filters' => array(), | |||||
'paginator' => array(), | |||||
'add_credit_history_form' => $addCreditHistoryForm, | |||||
] | |||||
'@LcCaracole/admin/credit/credit_detail.html.twig', | |||||
[ | |||||
'pageName' => Crud::PAGE_DETAIL, | |||||
'entity' => $context->getEntity(), | |||||
'batch_actions' => array(), | |||||
'entities' => array(), | |||||
'filters' => array(), | |||||
'paginator' => array(), | |||||
'add_credit_history_form' => $addCreditHistoryForm, | |||||
] | |||||
); | ); | ||||
} | } | ||||
class ProductFamilyFactory extends AbstractFactory | class ProductFamilyFactory extends AbstractFactory | ||||
{ | { | ||||
public function create(SectionInterface $section): ProductFamilyInterface | |||||
public function create(MerchantInterface $merchant): ProductFamilyInterface | |||||
{ | { | ||||
$productFamily = new ProductFamily(); | $productFamily = new ProductFamily(); | ||||
$productFamily->setSection($section); | |||||
$productFamilySectionPropertyFactory = new ProductFamilySectionPropertyFactory(); | |||||
foreach($merchant->getSections() as $section) { | |||||
$productFamilySectionProperty = $productFamilySectionPropertyFactory->create($section, $productFamily); | |||||
$productFamily->addProductFamilySectionProperty($productFamilySectionProperty); | |||||
} | |||||
return $productFamily; | return $productFamily; | ||||
} | } | ||||
} | } |
class TicketFactory extends SovTicketFactory | class TicketFactory extends SovTicketFactory | ||||
{ | { | ||||
use MerchantContextTrait; | |||||
use SectionContextTrait; | |||||
public function create(): TicketInterface | public function create(): TicketInterface | ||||
{ | { | ||||
$ticket = parent::create(); | $ticket = parent::create(); | ||||
$ticket->setMerchant($this->merchant); | |||||
$ticket->setSection($this->section); | |||||
return $ticket; | return $ticket; | ||||
} | } |
class UserMerchantFactory extends AbstractFactory | class UserMerchantFactory extends AbstractFactory | ||||
{ | { | ||||
// createUserMerchant | |||||
public function create(MerchantInterface $merchant, UserInterface $user = null): UserMerchantInterface | |||||
public function createBase(MerchantInterface $merchant): UserMerchantInterface | |||||
{ | { | ||||
$userMerchant = new UserMerchant(); | $userMerchant = new UserMerchant(); | ||||
$userMerchant->setMerchant($merchant); | $userMerchant->setMerchant($merchant); | ||||
return $userMerchant; | |||||
} | |||||
// createUserMerchant | |||||
public function create(MerchantInterface $merchant, UserInterface $user = null): UserMerchantInterface | |||||
{ | |||||
$userMerchant = $this->createBase($merchant); | |||||
$userMerchant->setUser($user); | $userMerchant->setUser($user); | ||||
return $userMerchant; | return $userMerchant; |
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
if($this->section) { | |||||
$query->filterBySection($this->section); | |||||
} | |||||
$this->addFilterBySectionOptionnal($query); | |||||
$query->filterIsOnlineAndOffline(); | $query->filterIsOnlineAndOffline(); | ||||
return $query; | return $query; | ||||
} | } | ||||
return $query; | return $query; | ||||
} | } | ||||
public function getByProductFamily(ProductFamilyInterface $productFamily, $query = null) | public function getByProductFamily(ProductFamilyInterface $productFamily, $query = null) | ||||
{ | { | ||||
$query = $this->createDefaultQuery($query); | $query = $this->createDefaultQuery($query); | ||||
$query | |||||
->filterProductFamily($productFamily); | |||||
$query->filterProductFamily($productFamily); | |||||
return $query->findOne(); | return $query->findOne(); | ||||
} | } | ||||
} | } |