abstract class AbstractCrudController extends EaAbstractCrudController | abstract class AbstractCrudController extends EaAbstractCrudController | ||||
{ | { | ||||
public function configureActions(Actions $actions): Actions | |||||
{ | |||||
if (in_array(TranslatableInterface::class, class_implements($this->getEntityFqcn()))) { | |||||
$actions->update(Crud::PAGE_INDEX, Action::EDIT, function (Action $action) { | |||||
return $action->setTemplatePath('@LcSov/crud/action/translatable.html.twig'); | |||||
}); | |||||
} | |||||
return $actions; | |||||
public function configureActions(Actions $actions): Actions | |||||
{ | |||||
if (in_array(TranslatableInterface::class, class_implements($this->getEntityFqcn()))) { | |||||
$actions->update( | |||||
Crud::PAGE_INDEX, | |||||
Action::EDIT, | |||||
function (Action $action) { | |||||
return $action->setTemplatePath('@LcSov/crud/action/translatable.html.twig'); | |||||
} | |||||
); | |||||
} | } | ||||
public function configureCrud(Crud $crud): Crud | |||||
{ | |||||
return $crud | |||||
->overrideTemplates([ | |||||
return $actions; | |||||
} | |||||
public function configureCrud(Crud $crud): Crud | |||||
{ | |||||
return $crud | |||||
->overrideTemplates( | |||||
[ | |||||
'crud/edit' => '@LcSov/crud/edit.html.twig', | 'crud/edit' => '@LcSov/crud/edit.html.twig', | ||||
'crud/new' => '@LcSov/crud/new.html.twig' | |||||
]) | |||||
// don't forget to add EasyAdmin's form theme at the end of the list | |||||
// (otherwise you'll lose all the styles for the rest of form fields) | |||||
->setFormThemes(['@LcSov/crud/form_theme.html.twig', '@FOSCKEditor/Form/ckeditor_widget.html.twig']); | |||||
} | |||||
'crud/new' => '@LcSov/crud/new.html.twig', | |||||
] | |||||
) | |||||
// don't forget to add EasyAdmin's form theme at the end of the list | |||||
// (otherwise you'll lose all the styles for the rest of form fields) | |||||
->setFormThemes(['@LcSov/crud/form_theme.html.twig', '@FOSCKEditor/Form/ckeditor_widget.html.twig']); | |||||
} | |||||
public function configureAssets(Assets $assets): Assets | |||||
{ | |||||
return $assets | |||||
// adds the CSS and JS assets associated to the given Webpack Encore entry | |||||
// it's equivalent to calling encore_entry_link_tags('...') and encore_entry_script_tags('...') | |||||
//->addWebpackEncoreEntry('admin-app') | |||||
public function configureAssets(Assets $assets): Assets | |||||
{ | |||||
return $assets | |||||
// adds the CSS and JS assets associated to the given Webpack Encore entry | |||||
// it's equivalent to calling encore_entry_link_tags('...') and encore_entry_script_tags('...') | |||||
//->addWebpackEncoreEntry('admin-app') | |||||
// the argument of these methods is passed to the asset() Twig function | |||||
// CSS assets are added just before the closing </head> element | |||||
// and JS assets are added just before the closing </body> element | |||||
->addJsFile('bundles/lc_sov/js/utils.js'); | |||||
} | |||||
// the argument of these methods is passed to the asset() Twig function | |||||
// CSS assets are added just before the closing </head> element | |||||
// and JS assets are added just before the closing </body> element | |||||
->addJsFile('bundles/lc_sov/js/utils.js'); | |||||
} | |||||
/* | |||||
public function configureFields(string $pageName): iterable | |||||
{ | |||||
return [ | |||||
IdField::new('id'), | |||||
TextField::new('title'), | |||||
TextEditorField::new('description'), | |||||
]; | |||||
} | |||||
*/ | |||||
/* | |||||
public function configureFields(string $pageName): iterable | |||||
{ | |||||
return [ | |||||
IdField::new('id'), | |||||
TextField::new('title'), | |||||
TextEditorField::new('description'), | |||||
]; | |||||
} | |||||
*/ | |||||
} | } |
namespace Lc\SovBundle\Controller\Admin; | namespace Lc\SovBundle\Controller\Admin; | ||||
use App\Entity\Page; | use App\Entity\Page; | ||||
use App\Entity\User; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard; | use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem; | use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController; | use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController; | ||||
use Lc\SovBundle\Doctrine\EntityManager; | |||||
use Lc\SovBundle\Model\User\UserInterface; | |||||
use Symfony\Component\HttpFoundation\Response; | use Symfony\Component\HttpFoundation\Response; | ||||
use Symfony\Component\Routing\Annotation\Route; | use Symfony\Component\Routing\Annotation\Route; | ||||
class DashboardController extends AbstractDashboardController | class DashboardController extends AbstractDashboardController | ||||
{ | { | ||||
public function index(): Response | |||||
{ | |||||
return $this->render('@LcSov/dashboard.html.twig'); | |||||
} | |||||
public function configureDashboard(): Dashboard | |||||
{ | |||||
return Dashboard::new() | |||||
// the name visible to end users | |||||
->setTitle('LA CLIC !') | |||||
// you can include HTML contents too (e.g. to link to an image) | |||||
->setTitle('<img src="assets/img/laclic.png" width="100px">') | |||||
// the path defined in this method is passed to the Twig asset() function | |||||
->setFaviconPath('favicon.svg') | |||||
// the domain used by default is 'messages' | |||||
->setTranslationDomain('lcadmin'); | |||||
} | |||||
public function configureCrud(): Crud | |||||
{ | |||||
$crud = Crud::new(); | |||||
return $crud | |||||
->addFormTheme('@FOSCKEditor/Form/ckeditor_widget.html.twig'); | |||||
} | |||||
public function index(): Response | |||||
{ | |||||
return $this->render('@LcSov/dashboard.html.twig'); | |||||
} | |||||
public function configureDashboard(): Dashboard | |||||
{ | |||||
return Dashboard::new() | |||||
// the name visible to end users | |||||
->setTitle('LA CLIC !') | |||||
// you can include HTML contents too (e.g. to link to an image) | |||||
->setTitle('<img src="assets/img/laclic.png" width="100px">') | |||||
// the path defined in this method is passed to the Twig asset() function | |||||
->setFaviconPath('favicon.svg') | |||||
// the domain used by default is 'messages' | |||||
->setTranslationDomain('lcadmin'); | |||||
} | |||||
public function configureCrud(): Crud | |||||
{ | |||||
$crud = Crud::new(); | |||||
return $crud | |||||
->addFormTheme('@FOSCKEditor/Form/ckeditor_widget.html.twig'); | |||||
} | |||||
public function configureMenuItems(): iterable | |||||
{ | |||||
return [ | |||||
MenuItem::linkToDashboard('Tableau de bord', 'fa fa-home'), | |||||
MenuItem::linkToCrud('Pages', 'fa fa-tags', Page::class), | |||||
/* | |||||
MenuItem::section('Blog'), | |||||
MenuItem::linkToCrud('Categories', 'fa fa-tags', Category::class), | |||||
MenuItem::linkToCrud('Blog Posts', 'fa fa-file-text', BlogPost::class), | |||||
MenuItem::section('Users'), | |||||
MenuItem::linkToCrud('Comments', 'fa fa-comment', Comment::class), | |||||
MenuItem::linkToCrud('Users', 'fa fa-user', User::class),*/ | |||||
//MenuItem::linkToLogout('Déconnexion', 'fa fa-exit'), | |||||
]; | |||||
} | |||||
} | } |
<?php | |||||
namespace Lc\SovBundle\Controller\Admin; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||||
abstract class UserCrudController extends AbstractCrudController | |||||
{ | |||||
public function configureFields(string $pageName): iterable | |||||
{ | |||||
return [ | |||||
TextField::new('email') | |||||
]; | |||||
} | |||||
} |