Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

72 lines
2.5KB

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