You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.7KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Controller\Product;
  3. use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
  4. use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
  5. use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
  6. use Lc\CaracoleBundle\Container\Order\OrderShopContainer;
  7. use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
  8. use Lc\CaracoleBundle\Controller\AbstractAdminController;
  9. use Lc\CaracoleBundle\Definition\ActionDefinition;
  10. use Lc\CaracoleBundle\Resolver\SectionResolver;
  11. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  12. use Symfony\Component\HttpFoundation\Response;
  13. abstract class ProductFamilyAdminController extends AbstractAdminController
  14. {
  15. public function configureCrud(Crud $crud): Crud
  16. {
  17. $crud = parent::configureCrud($crud);
  18. if($this->getRequestCrudAction() === ActionDefinition::SORT) {
  19. $crud->setDefaultSort(['position' => 'ASC']);
  20. }else{
  21. $crud->setDefaultSort(['id' => 'DESC']);
  22. }
  23. return $crud;
  24. }
  25. public function getRepositoryQuery() :RepositoryQueryInterface
  26. {
  27. return $this->get(ProductFamilyContainer::class)->getRepositoryQuery();
  28. }
  29. public function createEntity(string $entityFqcn)
  30. {
  31. return $this->getProductFamilyContainer()
  32. ->getFactory()
  33. ->create($this->getMerchantCurrent());
  34. }
  35. public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
  36. {
  37. $responseParameters = parent::configureResponseParameters($responseParameters);
  38. // affichage du filtre sur section
  39. $responseParameters->set('display_switch_section', true);
  40. return $responseParameters;
  41. }
  42. }