|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
-
- namespace Lc\CaracoleBundle\Controller\Section;
-
- use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
- use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
- use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
- use EasyCorp\Bundle\EasyAdminBundle\Field\TimeField;
- use Lc\CaracoleBundle\Container\Section\OpeningContainer;
- use Lc\CaracoleBundle\Controller\AdminControllerTrait;
- use Lc\CaracoleBundle\Factory\Section\OpeningFactory;
- use Lc\CaracoleBundle\Resolver\SectionResolver;
- use Lc\SovBundle\Controller\AbstractAdminController;
- use Lc\SovBundle\Repository\RepositoryQueryInterface;
-
- abstract class OpeningAdminController extends AbstractAdminController
- {
- use AdminControllerTrait;
-
- public function getRepositoryQuery() :RepositoryQueryInterface
- {
- return $this->get(OpeningContainer::class)->getRepositoryQuery();
- }
-
- public function configureFields(string $pageName): iterable
- {
- $fields = parent::configureFields($pageName);
-
- return array_merge(
- [
- ChoiceField::new('day')
- ->setRequired(true)
- ->setChoices(
- [
- 'Lundi' => 1,
- 'Mardi' => 2,
- 'Mercredi' => 3,
- 'Jeudi' => 4,
- 'Vendredi' => 5,
- 'Samedi' => 6,
- 'Dimanche' => 7,
- ]
- ),
- TimeField::new('timeStart')
- ->setRequired(false)
- ->setFormat('H:mm'),
- TimeField::new('timeEnd')
- ->setRequired(false)
- ->setFormat('H:mm'),
- AssociationField::new('groupUser'),
- ],
- $fields
- );
- }
-
- public function configureCrud(Crud $crud): Crud
- {
- $crud = parent::configureCrud($crud);
-
- $crud->setDefaultSort(['day' => 'ASC']);
-
- return $crud;
- }
-
- public function createEntity(string $entityFqcn)
- {
- return $this->get(OpeningContainer::class)
- ->getFactory()
- ->create($this->get(SectionResolver::class)->getCurrent());
- }
-
- }
|