Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

OpeningAdminController.php 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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->get(OpeningContainer::class)
  58. ->getFactory()
  59. ->create($this->get(SectionResolver::class)->getCurrent());
  60. }
  61. }