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.

ProductCategoryFieldDefinition.php 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace Lc\CaracoleBundle\Definition\Field\Product;
  3. use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
  4. use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
  5. use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
  6. use Lc\CaracoleBundle\Definition\Field\AbstractFieldDefinition;
  7. use Lc\CaracoleBundle\Repository\Product\ProductCategoryStore;
  8. use Lc\CaracoleBundle\Repository\Section\SectionStore;
  9. use Lc\SovBundle\Field\CKEditorField;
  10. use Lc\SovBundle\Field\ToggleField;
  11. use Lc\SovBundle\Translation\TranslatorAdmin;
  12. class ProductCategoryFieldDefinition extends AbstractFieldDefinition
  13. {
  14. protected SectionStore $sectionStore;
  15. protected ProductCategoryStore $productCategoryStore;
  16. public function __construct(
  17. TranslatorAdmin $translatorAdmin,
  18. SectionStore $sectionStore,
  19. ProductCategoryStore $productCategoryStore
  20. ) {
  21. parent::__construct($translatorAdmin);
  22. $this->sectionStore = $sectionStore;
  23. $this->productCategoryStore = $productCategoryStore;
  24. }
  25. public function configureIndex(): array
  26. {
  27. $fieldArray = ($this->section == null) ? ['section'] : [];
  28. return array_merge($fieldArray, [
  29. 'id',
  30. 'title',
  31. 'position',
  32. 'createdAt',
  33. 'updatedAt',
  34. 'status',
  35. 'saleStatus'
  36. ]);
  37. }
  38. public function configurePanels(): array
  39. {
  40. return [
  41. 'main',
  42. 'seo',
  43. 'conf'
  44. ];
  45. }
  46. public function configurePanelMain()
  47. {
  48. return [
  49. 'section',
  50. 'title',
  51. 'parent',
  52. 'description',
  53. 'isEligibleTicketRestaurant',
  54. 'saleStatus',
  55. 'status',
  56. ];
  57. }
  58. public function configureFields(): array
  59. {
  60. $productCategoryArray = $this->productCategoryStore
  61. ->setSection($this->section)
  62. ->getParents();
  63. return [
  64. 'title' => TextField::new('title')->setSortable(true),
  65. 'position' => NumberField::new('position')->setSortable(true),
  66. 'parent' => AssociationField::new('parent')
  67. ->setFormTypeOption('choices', $productCategoryArray),
  68. 'description' => CKEditorField::new('description'),
  69. 'saleStatus' => ToggleField::new('saleStatus')->setSortable(true),
  70. 'isEligibleTicketRestaurant' => ToggleField::new('isEligibleTicketRestaurant')->setSortable(true),
  71. ];
  72. }
  73. }