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.3KB

3 년 전
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. 'isEligibleTicketRestaurant'
  37. ]);
  38. }
  39. public function configurePanels(): array
  40. {
  41. return [
  42. 'main',
  43. 'seo',
  44. 'conf'
  45. ];
  46. }
  47. public function configureFields(): array
  48. {
  49. $productCategoryArray = $this->productCategoryStore
  50. ->setSection($this->section)
  51. ->getParents();
  52. return [
  53. 'title' => TextField::new('title')->setSortable(true),
  54. 'position' => NumberField::new('position')->setSortable(true),
  55. 'parent' => AssociationField::new('parent')
  56. ->setFormTypeOption('choices', $productCategoryArray),
  57. 'description' => CKEditorField::new('description'),
  58. 'saleStatus' => ToggleField::new('saleStatus')->setSortable(true),
  59. 'isEligibleTicketRestaurant' => ToggleField::new('isEligibleTicketRestaurant')->setSortable(true),
  60. ];
  61. }
  62. }