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.

74 rindas
2.9KB

  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 Lc\SovBundle\Repository\RepositoryQueryInterface;
  18. use Symfony\Component\HttpFoundation\Request;
  19. use Symfony\Component\HttpFoundation\Session\SessionFactory;
  20. use Symfony\Component\Routing\Annotation\Route;
  21. abstract class SectionAdminController extends AbstractAdminController
  22. {
  23. use AdminControllerTrait;
  24. public function getRepositoryQuery() :RepositoryQueryInterface
  25. {
  26. return $this->get(SectionContainer::class)->getRepositoryQuery();
  27. }
  28. public function configureFields(string $pageName): iterable
  29. {
  30. return array_merge(
  31. [
  32. FormField::addPanel('general'),
  33. TextField::new('title'),
  34. ChoiceField::new('cycleType')
  35. ->setRequired(true)
  36. ->hideOnIndex()
  37. ->setChoices(
  38. [
  39. 'Jour' => SectionModel::CYCLE_TYPE_DAY,
  40. 'Semaine' => SectionModel::CYCLE_TYPE_WEEK,
  41. 'Mois' => SectionModel::CYCLE_TYPE_MONTH,
  42. 'Année' => SectionModel::CYCLE_TYPE_YEAR,
  43. ]
  44. ),
  45. TextField::new('color')
  46. ->setRequired(true),
  47. NumberField::new('position')
  48. ->hideOnForm()
  49. ->hideOnIndex(),
  50. CKEditorField::new('description')
  51. ->hideOnIndex(),
  52. BooleanField::new('isDefault'),
  53. StatusField::new('status'),
  54. ],
  55. $this->getSeoPanel(),
  56. $this->getConfPanel(),
  57. );
  58. }
  59. public function createEntity(string $entityFqcn)
  60. {
  61. return $this->get(SectionContainer::class)
  62. ->getFactory()
  63. ->create($this->get(MerchantResolver::class)->getCurrent());
  64. }
  65. }