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.

68 satır
2.7KB

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