No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

72 líneas
2.3KB

  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. }