Nevar pievienot vairāk kā 25 tēmas
Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
|
- <?php
-
- namespace Lc\CaracoleBundle\Controller\Product;
-
- use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
- use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
- use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
- use Lc\CaracoleBundle\Container\Order\OrderShopContainer;
- use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
- use Lc\CaracoleBundle\Controller\AbstractAdminController;
- use Lc\CaracoleBundle\Definition\ActionDefinition;
- use Lc\CaracoleBundle\Resolver\SectionResolver;
- use Lc\SovBundle\Repository\RepositoryQueryInterface;
- use Symfony\Component\HttpFoundation\Response;
-
- abstract class ProductFamilyAdminController extends AbstractAdminController
- {
- public function configureCrud(Crud $crud): Crud
- {
- $crud = parent::configureCrud($crud);
-
- if ($this->getRequestCrudAction() === ActionDefinition::SORT) {
- $crud->setDefaultSort(['position' => 'ASC']);
- } else {
- $crud->setDefaultSort(['id' => 'DESC']);
- }
-
- return $crud;
- }
-
- public function getRepositoryQuery(): RepositoryQueryInterface
- {
- return $this->get(ProductFamilyContainer::class)->getRepositoryQuery();
- }
-
- public function createEntity(string $entityFqcn)
- {
- return $this->getProductFamilyContainer()
- ->getFactory()
- ->create($this->getMerchantCurrent());
- }
-
-
- public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
- {
- $responseParameters = parent::configureResponseParameters($responseParameters);
-
- $productFamiliesDto = [];
- $productFamilies = [];
- if ($responseParameters->get('entities')) {
- $productFamiliesDto = $responseParameters->get('entities');
- } elseif ($responseParameters->get('entity')) {
- $productFamiliesDto = [$responseParameters->get('entity')];
- }
-
- foreach ($productFamiliesDto as $productFamilyDto) {
- $productFamilies[] = $productFamilyDto->getInstance();
- }
-
- if($responseParameters->get('pageName') != 'new') {
- $this->getProductFamilyContainer()->getStore()
- ->setSection($this->getSectionCurrentDefault())
- ->getWithReductions($productFamilies);
- }
-
- // affichage du filtre sur section
- $responseParameters->set('display_switch_section', true);
-
- return $responseParameters;
- }
-
- }
|