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.

65 lines
2.5KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Controller\Section;
  3. use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
  4. use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
  5. use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
  6. use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
  7. use Lc\CaracoleBundle\Controller\AdminControllerTrait;
  8. use Lc\CaracoleBundle\Factory\Section\SectionFactory;
  9. use Lc\CaracoleBundle\Form\Section\OpeningsFormType;
  10. use Lc\CaracoleBundle\Model\Section\SectionModel;
  11. use Lc\SovBundle\Controller\AbstractAdminController;
  12. use Lc\SovBundle\Field\BooleanField;
  13. use Lc\SovBundle\Field\CKEditorField;
  14. use Lc\SovBundle\Field\StatusField;
  15. use Symfony\Component\HttpFoundation\Request;
  16. use Symfony\Component\Routing\Annotation\Route;
  17. abstract class SectionAdminController extends AbstractAdminController
  18. {
  19. use AdminControllerTrait;
  20. public function configureFields(string $pageName): iterable
  21. {
  22. return array_merge(
  23. [
  24. FormField::addPanel('general'),
  25. TextField::new('title'),
  26. ChoiceField::new('cycle')
  27. ->setRequired(true)
  28. ->hideOnIndex()
  29. ->setChoices(
  30. [
  31. 'Jour' => SectionModel::CYCLE_DAY,
  32. 'Semaine' => SectionModel::CYCLE_WEEK,
  33. 'Mois' => SectionModel::CYCLE_MONTH,
  34. 'Année' => SectionModel::CYCLE_YEAR,
  35. ]
  36. ),
  37. TextField::new('color')
  38. ->setRequired(true)
  39. ->hideOnIndex(),
  40. NumberField::new('position')
  41. ->hideOnForm()
  42. ->hideOnIndex(),
  43. CKEditorField::new('description')
  44. ->hideOnIndex(),
  45. BooleanField::new('isDefault', 'Section par défaut'),
  46. StatusField::new('status'),
  47. ],
  48. $this->getSeoPanel(),
  49. $this->getConfPanel(),
  50. );
  51. }
  52. public function createEntity(string $entityFqcn)
  53. {
  54. $factory = new SectionFactory();
  55. $currentMerchant = $this->get('merchant_resolver')->getCurrent();
  56. return $factory->create($currentMerchant);
  57. }
  58. }