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.

67 line
2.3KB

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