Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

88 lines
2.7KB

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