Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

49 lines
1.6KB

  1. <?php
  2. namespace Lc\SovBundle\Controller\Site;
  3. use EasyCorp\Bundle\EasyAdminBundle\Field\DateField;
  4. use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
  5. use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
  6. use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
  7. use Lc\SovBundle\Container\Site\NewsContainer;
  8. use Lc\SovBundle\Controller\AbstractAdminController;
  9. use Lc\SovBundle\Factory\Site\NewsFactory;
  10. use Lc\SovBundle\Field\CKEditorField;
  11. use Lc\SovBundle\Field\StatusField;
  12. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  13. abstract class NewsAdminController extends AbstractAdminController
  14. {
  15. public function getRepositoryQuery() :RepositoryQueryInterface
  16. {
  17. return $this->get(NewsContainer::class)->getRepositoryQuery();
  18. }
  19. public function configureFields(string $pageName): iterable
  20. {
  21. $panel = parent::configureFields($pageName);
  22. return array_merge(
  23. [
  24. FormField::addPanel('general'),
  25. TextField::new('title'),
  26. DateField::new('date')
  27. ->setFormat('d/MM/y'),
  28. NumberField::new('position')
  29. ->hideOnIndex()
  30. ->hideOnForm(),
  31. CKEditorField::new('description'),
  32. StatusField::new('status'),
  33. ],
  34. $panel
  35. );
  36. }
  37. public function createEntity(string $entityFqcn)
  38. {
  39. return $this->get(NewsContainer::class)->getFactory()->create();
  40. }
  41. }