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 lines
2.4KB

  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. return [
  23. ChoiceField::new('day')
  24. ->setRequired(true)
  25. ->setChoices(
  26. [
  27. 'Lundi' => 1,
  28. 'Mardi' => 2,
  29. 'Mercredi' => 3,
  30. 'Jeudi' => 4,
  31. 'Vendredi' => 5,
  32. 'Samedi' => 6,
  33. 'Dimanche' => 7,
  34. ]
  35. ),
  36. TimeField::new('timeStart')
  37. ->setRequired(false)
  38. ->setFormat('H:mm'),
  39. TimeField::new('timeEnd')
  40. ->setRequired(false)
  41. ->setFormat('H:mm'),
  42. AssociationField::new('groupUser'),
  43. ];
  44. }
  45. public function configureCrud(Crud $crud): Crud
  46. {
  47. $crud = parent::configureCrud($crud);
  48. $crud->setDefaultSort(['day' => 'ASC']);
  49. return $crud;
  50. }
  51. public function createEntity(string $entityFqcn)
  52. {
  53. return $this->getOpeningContainer()
  54. ->getFactory()
  55. ->create($this->getSectionCurrent());
  56. }
  57. }