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. $panel = parent::configureFields($pageName);
  23. return array_merge(
  24. [
  25. FormField::addPanel('general'),
  26. TextField::new('title'),
  27. ChoiceField::new('cycle')
  28. ->setRequired(true)
  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. $panel
  49. );
  50. }
  51. public function createEntity(string $entityFqcn)
  52. {
  53. $factory = new SectionFactory();
  54. $currentMerchant = $this->get('merchant_resolver')->getCurrent();
  55. return $factory->create($currentMerchant);
  56. }
  57. }