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 line
2.2KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Controller\Section;
  3. use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
  4. use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
  5. use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
  6. use EasyCorp\Bundle\EasyAdminBundle\Field\TimeField;
  7. use Lc\CaracoleBundle\Controller\AdminControllerTrait;
  8. use Lc\CaracoleBundle\Factory\Section\OpeningFactory;
  9. use Lc\SovBundle\Controller\AbstractAdminController;
  10. abstract class OpeningAdminController extends AbstractAdminController
  11. {
  12. use AdminControllerTrait;
  13. public function configureFields(string $pageName): iterable
  14. {
  15. $fields = parent::configureFields($pageName);
  16. return array_merge(
  17. [
  18. ChoiceField::new('day')
  19. ->setRequired(true)
  20. ->setChoices(
  21. [
  22. 'Lundi' => 1,
  23. 'Mardi' => 2,
  24. 'Mercredi' => 3,
  25. 'Jeudi' => 4,
  26. 'Vendredi' => 5,
  27. 'Samedi' => 6,
  28. 'Dimanche' => 7,
  29. ]
  30. ),
  31. TimeField::new('timeStart')
  32. ->setRequired(false)
  33. ->setFormat('H:mm'),
  34. TimeField::new('timeEnd')
  35. ->setRequired(false)
  36. ->setFormat('H:mm'),
  37. AssociationField::new('groupUser'),
  38. ],
  39. $fields
  40. );
  41. }
  42. public function configureCrud(Crud $crud): Crud
  43. {
  44. $crud = parent::configureCrud($crud);
  45. $crud->setDefaultSort(['day' => 'ASC']);
  46. return $crud;
  47. }
  48. public function createEntity(string $entityFqcn)
  49. {
  50. $factory = new OpeningFactory();
  51. $currentSection = $this->get('section_resolver')->getCurrent();
  52. return $factory->create($currentSection);
  53. }
  54. }