Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

SectionAdminController.php 2.7KB

3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace Lc\CaracoleBundle\Controller\Section;
  3. use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
  4. use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
  5. use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
  6. use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
  7. use Lc\CaracoleBundle\Container\Section\SectionContainer;
  8. use Lc\CaracoleBundle\Controller\AdminControllerTrait;
  9. use Lc\CaracoleBundle\Factory\Section\SectionFactory;
  10. use Lc\CaracoleBundle\Form\Section\OpeningsFormType;
  11. use Lc\CaracoleBundle\Model\Section\SectionModel;
  12. use Lc\CaracoleBundle\Resolver\MerchantResolver;
  13. use Lc\SovBundle\Controller\AbstractAdminController;
  14. use Lc\SovBundle\Field\BooleanField;
  15. use Lc\SovBundle\Field\CKEditorField;
  16. use Lc\SovBundle\Field\StatusField;
  17. use Symfony\Component\HttpFoundation\Request;
  18. use Symfony\Component\HttpFoundation\Session\SessionFactory;
  19. use Symfony\Component\Routing\Annotation\Route;
  20. abstract class SectionAdminController extends AbstractAdminController
  21. {
  22. use AdminControllerTrait;
  23. public function configureFields(string $pageName): iterable
  24. {
  25. return array_merge(
  26. [
  27. FormField::addPanel('general'),
  28. TextField::new('title'),
  29. ChoiceField::new('cycleType')
  30. ->setRequired(true)
  31. ->hideOnIndex()
  32. ->setChoices(
  33. [
  34. 'Jour' => SectionModel::CYCLE_TYPE_DAY,
  35. 'Semaine' => SectionModel::CYCLE_TYPE_WEEK,
  36. 'Mois' => SectionModel::CYCLE_TYPE_MONTH,
  37. 'Année' => SectionModel::CYCLE_TYPE_YEAR,
  38. ]
  39. ),
  40. TextField::new('color')
  41. ->setRequired(true),
  42. NumberField::new('position')
  43. ->hideOnForm()
  44. ->hideOnIndex(),
  45. CKEditorField::new('description')
  46. ->hideOnIndex(),
  47. BooleanField::new('isDefault'),
  48. BooleanField::new('isCommon'),
  49. StatusField::new('status'),
  50. ],
  51. $this->getSeoPanel(),
  52. $this->getConfPanel(),
  53. );
  54. }
  55. public function createEntity(string $entityFqcn)
  56. {
  57. return $this->get(SectionContainer::class)
  58. ->getFactory()
  59. ->create($this->get(MerchantResolver::class)->getCurrent());
  60. }
  61. }