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.

OpeningAdminController.php 2.3KB

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