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.

50 lines
1.7KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Controller\Product;
  3. use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
  4. use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
  5. use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
  6. use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
  7. use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
  8. use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
  9. use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
  10. use Lc\CaracoleBundle\Controller\AbstractAdminController;
  11. use Lc\CaracoleBundle\Definition\ActionDefinition;
  12. use Lc\SovBundle\Field\CKEditorField;
  13. use Lc\SovBundle\Field\StatusField;
  14. use Lc\SovBundle\Field\ToggleField;
  15. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  16. abstract class ProductCategoryAdminController extends AbstractAdminController
  17. {
  18. public function getRepositoryQuery() :RepositoryQueryInterface
  19. {
  20. return $this->getProductCategoryContainer()->getRepositoryQuery();
  21. }
  22. public function createEntity(string $entityFqcn)
  23. {
  24. return $this->getProductCategoryContainer()->getFactory()->create($this->getSectionCurrent());
  25. }
  26. public function configureFields(string $pageName): iterable
  27. {
  28. return $this->getProductCategoryContainer()->getFieldDefinition()
  29. ->setMerchant($this->getMerchantCurrent())
  30. ->setSection($this->getSectionCurrent())
  31. ->getFields($pageName);
  32. }
  33. public function configureActions(Actions $actions): Actions
  34. {
  35. $actions = parent::configureActions($actions);
  36. if(!$this->getSectionCurrent()) {
  37. $actions->disable(ActionDefinition::NEW);
  38. }
  39. return $actions;
  40. }
  41. }