您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

67 行
2.7KB

  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. StatusField::new('status'),
  49. ],
  50. $this->getSeoPanel(),
  51. $this->getConfPanel(),
  52. );
  53. }
  54. public function createEntity(string $entityFqcn)
  55. {
  56. return $this->get(SectionContainer::class)
  57. ->getFactory()
  58. ->create($this->get(MerchantResolver::class)->getCurrent());
  59. }
  60. }