You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 line
2.5KB

  1. <?php
  2. namespace Lc\SovBundle\Controller\Admin;
  3. use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
  4. use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
  5. use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
  6. use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
  7. use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController as EaAbstractCrudController;
  8. use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
  9. use Lc\SovBundle\Doctrine\Extension\TranslatableInterface;
  10. abstract class AbstractCrudController extends EaAbstractCrudController
  11. {
  12. public function configureActions(Actions $actions): Actions
  13. {
  14. if (in_array(TranslatableInterface::class, class_implements($this->getEntityFqcn()))) {
  15. $actions->update(
  16. Crud::PAGE_INDEX,
  17. Action::EDIT,
  18. function (Action $action) {
  19. return $action->setTemplatePath('@LcSov/crud/action/translatable.html.twig');
  20. }
  21. );
  22. }
  23. return $actions;
  24. }
  25. public function configureCrud(Crud $crud): Crud
  26. {
  27. return $crud
  28. ->overrideTemplates(
  29. [
  30. 'crud/edit' => '@LcSov/crud/edit.html.twig',
  31. 'crud/new' => '@LcSov/crud/new.html.twig',
  32. ]
  33. )
  34. // don't forget to add EasyAdmin's form theme at the end of the list
  35. // (otherwise you'll lose all the styles for the rest of form fields)
  36. ->setFormThemes(['@LcSov/crud/form_theme.html.twig', '@FOSCKEditor/Form/ckeditor_widget.html.twig']);
  37. }
  38. public function configureAssets(Assets $assets): Assets
  39. {
  40. return $assets
  41. // adds the CSS and JS assets associated to the given Webpack Encore entry
  42. // it's equivalent to calling encore_entry_link_tags('...') and encore_entry_script_tags('...')
  43. //->addWebpackEncoreEntry('admin-app')
  44. // the argument of these methods is passed to the asset() Twig function
  45. // CSS assets are added just before the closing </head> element
  46. // and JS assets are added just before the closing </body> element
  47. ->addJsFile('bundles/lc_sov/js/utils.js');
  48. }
  49. /*
  50. public function configureFields(string $pageName): iterable
  51. {
  52. return [
  53. IdField::new('id'),
  54. TextField::new('title'),
  55. TextEditorField::new('description'),
  56. ];
  57. }
  58. */
  59. }