Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

OpeningAdminController.php 2.3KB

pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
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\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. }