Browse Source

Merge branch 'develop'

tags/0.1
Guillaume 3 years ago
parent
commit
7823d12b03
17 changed files with 381 additions and 267 deletions
  1. +180
    -149
      Controller/Admin/AbstractCrudController.php
  2. +42
    -41
      Controller/Admin/DashboardController.php
  3. +5
    -0
      Controller/Admin/UserController.php
  4. +1
    -1
      Field/CollectionField.php
  5. +3
    -1
      Field/FileManagerField.php
  6. +2
    -2
      Field/GalleryManagerField.php
  7. +2
    -0
      Field/ImageManagerField.php
  8. +12
    -9
      Form/Type/User/ChangePasswordFormType.php
  9. +5
    -2
      Form/Type/User/ProfileFormType.php
  10. +2
    -0
      Resources/assets/app/adminlte/field/filemanager/app.filemanager.js
  11. +45
    -22
      Resources/translations/admin.fr.yaml
  12. +6
    -4
      Resources/views/adminlte/crud/_form.html.twig
  13. +6
    -5
      Resources/views/adminlte/crud/action/translatable.html.twig
  14. +27
    -10
      Resources/views/adminlte/crud/form_theme.html.twig
  15. +4
    -2
      Resources/views/adminlte/layout.html.twig
  16. +32
    -18
      Translation/TranslatorAdmin.php
  17. +7
    -1
      Twig/TwigExtension.php

+ 180
- 149
Controller/Admin/AbstractCrudController.php View File

use Lc\SovBundle\Field\CollectionField; use Lc\SovBundle\Field\CollectionField;
use Lc\SovBundle\Field\GalleryManagerField; use Lc\SovBundle\Field\GalleryManagerField;
use Lc\SovBundle\Form\Type\Crud\PositionType; use Lc\SovBundle\Form\Type\Crud\PositionType;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
{ {
protected $session; protected $session;
protected $request; protected $request;

public function __construct(SessionInterface $session, RequestStack $request, EntityManager $em, Environment $twig)
protected $translatorAdmin;

public function __construct(
SessionInterface $session,
RequestStack $request,
EntityManager $em,
Environment $twig,
TranslatorAdmin $translatorAdmin
)
{ {
$this->session = $session; $this->session = $session;
$this->request = $request; $this->request = $request;
$this->em = $em; $this->em = $em;
$this->twig = $twig; $this->twig = $twig;
$this->translatorAdmin = $translatorAdmin;
} }


public function configureActions(Actions $actions): Actions public function configureActions(Actions $actions): Actions
/* Translatable */ /* Translatable */
if ($this->isInstanceOf(TranslatableInterface::class)) { if ($this->isInstanceOf(TranslatableInterface::class)) {
$actions->update( $actions->update(
Crud::PAGE_INDEX,
Action::EDIT,
function (Action $action) {
$action->setTemplatePath('@LcSov/adminlte/crud/action/translatable.html.twig');
Crud::PAGE_INDEX,
Action::EDIT,
function (Action $action) {
$action->setTemplatePath('@LcSov/adminlte/crud/action/translatable.html.twig');


return $action;
}
return $action;
}
); );
} }


/* Boutons des actions dans les listes */ /* Boutons des actions dans les listes */
$actionsArray[Crud::PAGE_INDEX] = [ $actionsArray[Crud::PAGE_INDEX] = [
Action::NEW => [
'icon' => 'plus',
'label' => 'Créer',
'add_class' => 'btn-sm'
],
Action::EDIT => [
'class' => 'btn btn-sm btn-primary',
'icon' => 'edit',
'label' => false,
'html_attributes' => array('data-toggle' => 'tooltip', 'title' => 'Éditer')
],
Action::DELETE => [
'icon' => 'trash',
'dropdown' => true,
],
Action::BATCH_DELETE => [
'class' => 'btn btn-sm btn-danger',
'icon' => 'trash',
],
Action::NEW => [
'icon' => 'plus',
'label' => $this->translatorAdmin->transAction('create'),
'add_class' => 'btn-sm'
],
Action::EDIT => [
'class' => 'btn btn-sm btn-primary',
'icon' => 'edit',
'label' => false,
'html_attributes' => array(
'data-toggle' => 'tooltip',
'title' => $this->translatorAdmin->transAction('edit')
)
],
Action::DELETE => [
'icon' => 'trash',
'dropdown' => true,
'label' => $this->translatorAdmin->transAction('delete')
],
Action::BATCH_DELETE => [
'class' => 'btn btn-sm btn-danger',
'icon' => 'trash',
'label' => $this->translatorAdmin->transAction('delete')
],
]; ];


/* Boutons des actions dans l'édition */ /* Boutons des actions dans l'édition */


$actionSaveAndReturn = [ $actionSaveAndReturn = [
'add_class' => 'float-right',
'icon' => 'check',
'add_class' => 'float-right',
'icon' => 'check',
'label' => $this->translatorAdmin->transAction('save_and_return')
]; ];
$actionIndex = [ $actionIndex = [
'icon' => 'chevron-left',
'class' => 'btn btn-link',
'icon' => 'chevron-left',
'class' => 'btn btn-link',
'label' => $this->translatorAdmin->transAction('back_index')
]; ];


$actionsArray[Crud::PAGE_EDIT] = [ $actionsArray[Crud::PAGE_EDIT] = [
Action::SAVE_AND_CONTINUE => [
'class' => 'btn btn-info float-right',
],
Action::DELETE => [
'icon' => 'trash',
'class' => 'btn btn-outline-danger action-delete',
],
Action::SAVE_AND_RETURN => $actionSaveAndReturn,
Action::INDEX => $actionIndex,
Action::SAVE_AND_CONTINUE => [
'class' => 'btn btn-info float-right',
'label' => $this->translatorAdmin->transAction('save_and_continue')
],
Action::DELETE => [
'icon' => 'trash',
'class' => 'btn btn-outline-danger action-delete',
'label' => $this->translatorAdmin->transAction('delete')
],
Action::SAVE_AND_RETURN => $actionSaveAndReturn,
Action::INDEX => $actionIndex,
]; ];


$actionsArray[Crud::PAGE_NEW] = [ $actionsArray[Crud::PAGE_NEW] = [
Action::SAVE_AND_ADD_ANOTHER => [
'class' => 'btn btn-info float-right',
],
Action::SAVE_AND_RETURN => $actionSaveAndReturn,
Action::INDEX => $actionIndex,
Action::SAVE_AND_ADD_ANOTHER => [
'class' => 'btn btn-info float-right',
'label' => $this->translatorAdmin->transAction('save_and_add_another')
],
Action::SAVE_AND_RETURN => $actionSaveAndReturn,
Action::INDEX => $actionIndex,
]; ];


$actions->add(Crud::PAGE_EDIT, Action::INDEX); $actions->add(Crud::PAGE_EDIT, Action::INDEX);
$actions->add(Crud::PAGE_NEW, Action::INDEX); $actions->add(Crud::PAGE_NEW, Action::INDEX);


if ($this->isInstanceOf(SortableInterface::class)) { if ($this->isInstanceOf(SortableInterface::class)) {
$sortAction = Action::new('sort', 'Ordonner', 'fa fa-sort')
->linkToCrudAction('sort')
->setCssClass('btn btn-sm btn-success')
->createAsGlobalAction();
$sortAction = Action::new('sort', $this->translatorAdmin->transAction('sort'), 'fa fa-sort')
->linkToCrudAction('sort')
->setCssClass('btn btn-sm btn-success')
->createAsGlobalAction();


$actions->add(Crud::PAGE_INDEX, $sortAction); $actions->add(Crud::PAGE_INDEX, $sortAction);
} }




if ($this->isInstanceOf(TreeInterface::class)) { if ($this->isInstanceOf(TreeInterface::class)) {
$indexChildAction = Action::new('index_children', 'Afficher les enfants', 'fa fa-list')
->linkToCrudAction(Action::INDEX)
->setLabel('')
->setHtmlAttributes(array('data-toggle' => 'tooltip', 'title' => 'Afficher les enfants'))
->setTemplatePath('@LcSov/adminlte/crud/action/index_children.html.twig')
->setCssClass('btn btn-sm btn-success');

$backParentAction = Action::new('index_parent', 'Retour au parent', 'fa fa-chevron-left')
->linkToCrudAction(Action::INDEX)
->setCssClass('btn btn-sm btn-info')
->createAsGlobalAction();
$indexChildAction = Action::new(
'index_children',
$this->translatorAdmin->transAction('index_children'),
'fa fa-list'
)
->linkToCrudAction(Action::INDEX)
->setLabel('')
->setHtmlAttributes(array('data-toggle' => 'tooltip', 'title' => 'Afficher les enfants'))
->setTemplatePath('@LcSov/adminlte/crud/action/index_children.html.twig')
->setCssClass('btn btn-sm btn-success');

$backParentAction = Action::new(
'index_parent',
$this->translatorAdmin->transAction('index_parent'),
'fa fa-chevron-left'
)
->linkToCrudAction(Action::INDEX)
->setCssClass('btn btn-sm btn-info')
->createAsGlobalAction();


$actions->add(Crud::PAGE_INDEX, $backParentAction); $actions->add(Crud::PAGE_INDEX, $backParentAction);
$actions->add(Crud::PAGE_INDEX, $indexChildAction); $actions->add(Crud::PAGE_INDEX, $indexChildAction);
foreach ($actionsArray as $crudActionName => $actionsStyle) { foreach ($actionsArray as $crudActionName => $actionsStyle) {
foreach ($actionsStyle as $actionName => $button) { foreach ($actionsStyle as $actionName => $button) {
$actions->update( $actions->update(
$crudActionName,
$actionName,
function (Action $action) use ($button) {
if (isset($button['add_class'])) {
$action->addCssClass($button['add_class']);
}

if (isset($button['class'])) {
$action->setCssClass($button['class']);
}

if (isset($button['icon'])) {
$action->setIcon('fa fa-' . $button['icon']);
}

if (isset($button['label'])) {
$action->setLabel($button['label']);
}

if (isset($button['dropdown']) && $button['dropdown']) {
$action->addCssClass('in-dropdown');
}

if (isset($button['html_attributes']) && $button['html_attributes']) {
$action->setHtmlAttributes($button['html_attributes']);
}

return $action;
$crudActionName,
$actionName,
function (Action $action) use ($button) {
if (isset($button['add_class'])) {
$action->addCssClass($button['add_class']);
}

if (isset($button['class'])) {
$action->setCssClass($button['class']);
}

if (isset($button['icon'])) {
$action->setIcon('fa fa-' . $button['icon']);
} }

if (isset($button['label'])) {
$action->setLabel($button['label']);
}

if (isset($button['dropdown']) && $button['dropdown']) {
$action->addCssClass('in-dropdown');
}

if (isset($button['html_attributes']) && $button['html_attributes']) {
$action->setHtmlAttributes($button['html_attributes']);
}

return $action;
}
); );
} }
} }
$this->session->set($paramSessionListMaxResults, $requestListMaxResults); $this->session->set($paramSessionListMaxResults, $requestListMaxResults);
} }
$maxResults = $this->session->get($paramSessionListMaxResults) ? $this->session->get( $maxResults = $this->session->get($paramSessionListMaxResults) ? $this->session->get(
$paramSessionListMaxResults
$paramSessionListMaxResults
) : 30; ) : 30;


$crud->setPaginatorPageSize($maxResults); $crud->setPaginatorPageSize($maxResults);


public function configureFields(string $pageName): iterable public function configureFields(string $pageName): iterable
{ {
$seoPanel = $confPanel = array();

if ($this->isInstanceOf(SortableInterface::class)) { if ($this->isInstanceOf(SortableInterface::class)) {
$seoPanel = [ $seoPanel = [
FormField::addPanel('seo'),
TextField::new('metaTitle')->setLabel('Meta Title')->setHelp(
'Affiché dans les résultats de recherche Google'
)->hideOnIndex(),
TextareaField::new('metaDescription')->setLabel('Meta description')->setHelp(
'Affiché dans les résultats de recherche Google'
FormField::addPanel('seo')->setTemplateName('crud/field/generic'),
TextField::new('metaTitle')->setLabel('Meta Title')->setHelp(
'Affiché dans les résultats de recherche Google'
)->hideOnIndex(),
TextareaField::new('metaDescription')->setLabel('Meta description')->setHelp(
'Affiché dans les résultats de recherche Google'
)->hideOnIndex(),
CollectionField::new('oldUrls')
->setFormTypeOption('entry_type', TextType::class)->setLabel(
'Anciennes urls du document'
)->hideOnIndex(), )->hideOnIndex(),
CollectionField::new('oldUrls')
->setFormTypeOption('entry_type', TextType::class)->setLabel(
'Anciennes urls du document'
)->hideOnIndex(),
]; ];
} }


if ($this->isInstanceOf(DevAliasInterface::class)) { if ($this->isInstanceOf(DevAliasInterface::class)) {
$confPanel = [ $confPanel = [
FormField::addPanel('configuration'),
TextField::new('devAlias')->hideOnIndex(),
FormField::addPanel('configuration')->setTemplateName('crud/field/generic'),
TextField::new('devAlias')->hideOnIndex(),
]; ];
} }




$fields = FieldCollection::new($this->configureFields(Crud::PAGE_INDEX)); $fields = FieldCollection::new($this->configureFields(Crud::PAGE_INDEX));
$filters = $this->get(FilterFactory::class)->create( $filters = $this->get(FilterFactory::class)->create(
$context->getCrud()->getFiltersConfig(),
$fields,
$context->getEntity()
$context->getCrud()->getFiltersConfig(),
$fields,
$context->getEntity()
); );
$queryBuilder = $this->createIndexQueryBuilder($context->getSearch(), $context->getEntity(), $fields, $filters); $queryBuilder = $this->createIndexQueryBuilder($context->getSearch(), $context->getEntity(), $fields, $filters);
$paginator = $this->get(PaginatorFactory::class)->create($queryBuilder); $paginator = $this->get(PaginatorFactory::class)->create($queryBuilder);
$this->get(EntityFactory::class)->processFieldsForAll($entities, $fields); $this->get(EntityFactory::class)->processFieldsForAll($entities, $fields);


$sortableForm = $this->createFormBuilder(array('entities', $paginator->getResults())) $sortableForm = $this->createFormBuilder(array('entities', $paginator->getResults()))
->add(
'entities',
CollectionType::class,
array(
'required' => true,
'allow_add' => true,
'entry_type' => PositionType::class,
)
->add(
'entities',
CollectionType::class,
array(
'required' => true,
'allow_add' => true,
'entry_type' => PositionType::class,
) )
->getForm();
)
->getForm();


$entityManager = $this->getDoctrine()->getManagerForClass($this->getEntityFqcn()); $entityManager = $this->getDoctrine()->getManagerForClass($this->getEntityFqcn());
$repository = $entityManager->getRepository($this->getEntityFqcn()); $repository = $entityManager->getRepository($this->getEntityFqcn());
} }


$url = $this->get(AdminUrlGenerator::class) $url = $this->get(AdminUrlGenerator::class)
->setAction(Action::INDEX)
->generateUrl();
$this->addFlash('success', 'Position modifié', array());
->setAction(Action::INDEX)
->generateUrl();
$this->addFlash('success', $this->translatorAdmin->transFlashMessage('sort'), array());


return $this->redirect($url); return $this->redirect($url);
} }


$responseParameters = $this->configureResponseParameters( $responseParameters = $this->configureResponseParameters(
KeyValueStore::new(
[
'pageName' => Crud::PAGE_INDEX,
'templatePath' => '@LcSov/adminlte/crud/sort.html.twig',
'entities' => $entities,
'paginator' => $paginator,
'global_actions' => array(),
'batch_actions' => array(),
'filters' => $filters,
'sortable_form' => $sortableForm,
]
)
KeyValueStore::new(
[
'pageName' => Crud::PAGE_INDEX,
'templatePath' => '@LcSov/adminlte/crud/sort.html.twig',
'entities' => $entities,
'paginator' => $paginator,
'global_actions' => array(),
'batch_actions' => array(),
'filters' => $filters,
'sortable_form' => $sortableForm,
]
)
); );
$responseParameters->set('fields', $this->configureFields('index')); $responseParameters->set('fields', $this->configureFields('index'));
$event = new AfterCrudActionEvent($context, $responseParameters); $event = new AfterCrudActionEvent($context, $responseParameters);
} }


public function createIndexQueryBuilder( public function createIndexQueryBuilder(
SearchDto $searchDto,
EntityDto $entityDto,
FieldCollection $fields,
FilterCollection $filters
): QueryBuilder {
SearchDto $searchDto,
EntityDto $entityDto,
FieldCollection $fields,
FilterCollection $filters
): QueryBuilder
{
$queryBuilder = parent::createIndexQueryBuilder( $queryBuilder = parent::createIndexQueryBuilder(
$searchDto,
$entityDto,
$fields,
$filters
$searchDto,
$entityDto,
$fields,
$filters
); );


if ($this->isInstanceOf(TreeInterface::class)) { if ($this->isInstanceOf(TreeInterface::class)) {
} }


public function createSortQueryBuilder( public function createSortQueryBuilder(
SearchDto $searchDto,
EntityDto $entityDto,
FieldCollection $fields,
FilterCollection $filters
): QueryBuilder {
SearchDto $searchDto,
EntityDto $entityDto,
FieldCollection $fields,
FilterCollection $filters
): QueryBuilder
{
$queryBuilder = parent::createIndexQueryBuilder( $queryBuilder = parent::createIndexQueryBuilder(
$searchDto,
$entityDto,
$fields,
$filters
$searchDto,
$entityDto,
$fields,
$filters
); );


if ($this->isInstanceOf(TreeInterface::class)) { if ($this->isInstanceOf(TreeInterface::class)) {


public function edit(AdminContext $context) public function edit(AdminContext $context)
{ {
$response = parent::edit($context); ;
$response = parent::edit($context);;


// on vide le flash bag si édition en ajax (notification déjà affichée en Javascript) // on vide le flash bag si édition en ajax (notification déjà affichée en Javascript)
if ($context->getRequest()->isXmlHttpRequest()) { if ($context->getRequest()->isXmlHttpRequest()) {
$this->session->getFlashBag()->clear() ;
$this->session->getFlashBag()->clear();
} }


return $response ;
return $response;
} }


public function isInstanceOf(string $interfaceName): bool public function isInstanceOf(string $interfaceName): bool

+ 42
- 41
Controller/Admin/DashboardController.php View File

public function configureDashboard(): Dashboard public function configureDashboard(): Dashboard
{ {
return Dashboard::new() 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('admin');
// 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('admin');
} }


public function configureAssets(): Assets public function configureAssets(): Assets
$assets->addWebpackEncoreEntry('adminlte-index'); $assets->addWebpackEncoreEntry('adminlte-index');
$assets->addWebpackEncoreEntry('adminlte-form'); $assets->addWebpackEncoreEntry('adminlte-form');
$assets->addWebpackEncoreEntry('adminlte-sort'); $assets->addWebpackEncoreEntry('adminlte-sort');
$assets->addWebpackEncoreEntry('adminlte-field-collection');
$assets->addWebpackEncoreEntry('adminlte-field-filemanager');


return $assets; return $assets;
} }
// user menu with some menu items already created ("sign out", "exit impersonation", etc.) // user menu with some menu items already created ("sign out", "exit impersonation", etc.)
// if you prefer to create the user menu from scratch, use: return UserMenu::new()->... // if you prefer to create the user menu from scratch, use: return UserMenu::new()->...
return parent::configureUserMenu($user) return parent::configureUserMenu($user)
// use the given $user object to get the user name
->setName($user->getName())
// use this method if you don't want to display the name of the user
//->displayUserName(false)
->displayUserAvatar(false)
// you can also pass an email address to use gravatar's service
->setGravatarEmail($user->getEmail())
// use the given $user object to get the user name
->setName($user->getName())
// use this method if you don't want to display the name of the user
//->displayUserName(false)
->displayUserAvatar(false)
// you can also pass an email address to use gravatar's service
->setGravatarEmail($user->getEmail())


// you can use any type of menu item, except submenus
->setMenuItems(
[
//MenuItem::linkToRoute('My Profile', 'fa fa-id-card', '', ['...' => '...']),
MenuItem::linkToLogout('Déconnexion', 'sign-out-alt'),
//MenuItem::linkToLogout('Déconnexion', 'sign-out-alt')
]
);
// you can use any type of menu item, except submenus
->setMenuItems(
[
//MenuItem::linkToRoute('My Profile', 'fa fa-id-card', '', ['...' => '...']),
MenuItem::linkToLogout('Déconnexion', 'sign-out-alt'),
//MenuItem::linkToLogout('Déconnexion', 'sign-out-alt')
]
);
} }


public function configureCrud(): Crud public function configureCrud(): Crud
$crud = Crud::new(); $crud = Crud::new();


return $crud return $crud
->overrideTemplates(
[
'layout' => '@LcSov/adminlte/layout.html.twig',
'main_menu' => '@LcSov/adminlte/block/menu.html.twig',
'crud/index' => '@LcSov/adminlte/crud/index.html.twig',
'crud/paginator' => '@LcSov/adminlte/crud/paginator.html.twig',
'crud/edit' => '@LcSov/adminlte/crud/edit.html.twig',
'crud/new' => '@LcSov/adminlte/crud/new.html.twig',
'flash_messages' => '@LcSov/adminlte/block/flash_messages.html.twig',
]
)
->setFormThemes(
[
'@LcSov/adminlte/crud/form_theme.html.twig',
'@FOSCKEditor/Form/ckeditor_widget.html.twig'
]
)
;
->overrideTemplates(
[
'layout' => '@LcSov/adminlte/layout.html.twig',
'main_menu' => '@LcSov/adminlte/block/menu.html.twig',
'crud/index' => '@LcSov/adminlte/crud/index.html.twig',
'crud/paginator' => '@LcSov/adminlte/crud/paginator.html.twig',
'crud/edit' => '@LcSov/adminlte/crud/edit.html.twig',
'crud/new' => '@LcSov/adminlte/crud/new.html.twig',
'flash_messages' => '@LcSov/adminlte/block/flash_messages.html.twig',
]
)
->setFormThemes(
[
'@LcSov/adminlte/crud/form_theme.html.twig',
'@FOSCKEditor/Form/ckeditor_widget.html.twig'
]
);
} }


} }

+ 5
- 0
Controller/Admin/UserController.php View File

use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Translation\TranslatableMessage;


class UserController extends AbstractController class UserController extends AbstractController
{ {


$this->em->update($user); $this->em->update($user);
$this->em->flush(); $this->em->flush();

$this->addFlash('success', new TranslatableMessage('form.account_profile.message.success', [], 'admin'));
} }


return $this->render( return $this->render(


$this->em->update($user); $this->em->update($user);
$this->em->flush(); $this->em->flush();

$this->addFlash('success', new TranslatableMessage('form.account_password.message.success', [], 'admin'));
} }


return $this->render( return $this->render(

+ 1
- 1
Field/CollectionField.php View File

->setLabel($label) ->setLabel($label)
->setTemplatePath('@LcSov/adminlte/crud/field/collection.html.twig') ->setTemplatePath('@LcSov/adminlte/crud/field/collection.html.twig')
->setFormType(CollectionType::class) ->setFormType(CollectionType::class)
->addWebpackEncoreEntries('adminlte-field-collection')
/*->addWebpackEncoreEntries('adminlte-field-collection')*/
->setFormTypeOption('allow_add', true) ->setFormTypeOption('allow_add', true)
->setFormTypeOption('allow_delete', true) ->setFormTypeOption('allow_delete', true)
->setFormTypeOption('entry_options', array('label' => false)) ->setFormTypeOption('entry_options', array('label' => false))

+ 3
- 1
Field/FileManagerField.php View File

->setProperty($propertyName) ->setProperty($propertyName)
->setLabel($label) ->setLabel($label)
->setTemplatePath('@LcSov/adminlte/crud/field/file.html.twig') ->setTemplatePath('@LcSov/adminlte/crud/field/file.html.twig')
->addWebpackEncoreEntries('adminlte-field-filemanager')
/*->addWebpackEncoreEntries('adminlte-field-filemanager')*/
->setCustomOption('managerDir', 'file')
->setCustomOption('type', 'file')
->setFormType(FileManagerType::class) ->setFormType(FileManagerType::class)
->addCssClass('field-text') ->addCssClass('field-text')
->setCustomOption(self::OPTION_MAX_LENGTH, null) ->setCustomOption(self::OPTION_MAX_LENGTH, null)

+ 2
- 2
Field/GalleryManagerField.php View File

->setTemplatePath('@LcSov/adminlte/crud/field/collection.html.twig') ->setTemplatePath('@LcSov/adminlte/crud/field/collection.html.twig')
->setFormType(CollectionType::class) ->setFormType(CollectionType::class)
->addCssClass('field-collection') ->addCssClass('field-collection')
->addWebpackEncoreEntries('adminlte-field-collection')
->addWebpackEncoreEntries('adminlte-field-filemanager')
/*->addWebpackEncoreEntries('adminlte-field-collection')
->addWebpackEncoreEntries('adminlte-field-filemanager')*/
->setFormTypeOption('allow_add', true) ->setFormTypeOption('allow_add', true)
->setFormTypeOption('allow_delete', true) ->setFormTypeOption('allow_delete', true)
->setFormTypeOption('entry_options', array('label'=> false)) ->setFormTypeOption('entry_options', array('label'=> false))

+ 2
- 0
Field/ImageManagerField.php View File

->setTemplatePath('@LcSov/adminlte/crud/field/image.html.twig') ->setTemplatePath('@LcSov/adminlte/crud/field/image.html.twig')
->addWebpackEncoreEntries('adminlte-field-filemanager') ->addWebpackEncoreEntries('adminlte-field-filemanager')
->setFormType(FileManagerType::class) ->setFormType(FileManagerType::class)
->setCustomOption('managerDir', 'image')
->setCustomOption('type', 'image')
->addCssClass('field-text') ->addCssClass('field-text')
->setCustomOption(self::OPTION_MAX_LENGTH, null) ->setCustomOption(self::OPTION_MAX_LENGTH, null)
->setCustomOption(self::OPTION_RENDER_AS_HTML, false); ->setCustomOption(self::OPTION_RENDER_AS_HTML, false);

+ 12
- 9
Form/Type/User/ChangePasswordFormType.php View File



use Lc\SovBundle\Doctrine\EntityManager; use Lc\SovBundle\Doctrine\EntityManager;
use Lc\SovBundle\Model\User\UserInterface; use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType; use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType; use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
class ChangePasswordFormType extends AbstractType class ChangePasswordFormType extends AbstractType
{ {


protected $em ;
protected $em;
protected $translatorAdmin;


public function __construct(EntityManager $em)
public function __construct(EntityManager $em, TranslatorAdmin $translatorAdmin)
{ {
$this->em = $em ;
$this->em = $em;
$this->translatorAdmin = $translatorAdmin;
} }


/** /**
'current_password', 'current_password',
PasswordType::class, PasswordType::class,
[ [
'label' => 'form.change_password.current_password',
'label' => 'form.account_password.field.current_password',
'mapped' => false, 'mapped' => false,
'constraints' => [ 'constraints' => [
new NotBlank(), new NotBlank(),
); );


$builder->add( $builder->add(
'plainPassword',
'plain_password',
RepeatedType::class, RepeatedType::class,
[ [
'type' => PasswordType::class, 'type' => PasswordType::class,
'mapped' => false, 'mapped' => false,
'first_options' => ['label' => 'form.change_password.new_password'],
'second_options' => ['label' => 'form.change_password.new_password_repeat'],
'invalid_message' => 'Les deux mots de passe ne correspondent pas.',
'first_options' => ['label' => 'form.account_password.field.new_password'],
'second_options' => ['label' => 'form.account_password.field.new_password_repeat'],
'invalid_message' => $this->translatorAdmin->trans('form.account_password.message.invalid_passwords'),
] ]
); );


'submit', 'submit',
SubmitType::class, SubmitType::class,
array( array(
'label' => new TranslatableMessage('action.save', [], 'admin')
'label' => $this->translatorAdmin->transAction('save')
) )
); );
} }

+ 5
- 2
Form/Type/User/ProfileFormType.php View File

use Lc\SovBundle\Doctrine\EntityManager; use Lc\SovBundle\Doctrine\EntityManager;
use Lc\SovBundle\Model\File\FileInterface; use Lc\SovBundle\Model\File\FileInterface;
use Lc\SovBundle\Model\User\UserInterface; use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType; use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
class ProfileFormType extends AbstractType class ProfileFormType extends AbstractType
{ {
protected $em; protected $em;
protected $translatorAdmin;


public function __construct(EntityManager $em)
public function __construct(EntityManager $em, TranslatorAdmin $translatorAdmin)
{ {
$this->em = $em; $this->em = $em;
$this->translatorAdmin = $translatorAdmin;
} }


public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
'submit', 'submit',
SubmitType::class, SubmitType::class,
[ [
'label' => new TranslatableMessage('action.save', [], 'admin')
'label' => $this->translatorAdmin->transAction('save')
] ]
); );
} }

+ 2
- 0
Resources/assets/app/adminlte/field/filemanager/app.filemanager.js View File

let $field = $(this); let $field = $(this);
$('#' + $field.data('id')).val(""); $('#' + $field.data('id')).val("");
$('#' + $field.data('id') + '_preview').prop('src',""); $('#' + $field.data('id') + '_preview').prop('src',"");
$('#' + $field.data('id') + '_preview_text').html('Aucun fichier');
}); });
$('.lc-filemanager-open').off('click'); $('.lc-filemanager-open').off('click');
$('.lc-filemanager-open').on('click', function (e) { $('.lc-filemanager-open').on('click', function (e) {
var path = $(this).attr('data-path') var path = $(this).attr('data-path')
$('#' + $field.data('id')).val(path); $('#' + $field.data('id')).val(path);
$('#' + $field.data('id') + '_preview').prop('src',path); $('#' + $field.data('id') + '_preview').prop('src',path);
$('#' + $field.data('id') + '_preview_text').html(path);
$('#lc-filemanager-modal').modal('hide'); $('#lc-filemanager-modal').modal('hide');
}); });
}); });

+ 45
- 22
Resources/translations/admin.fr.yaml View File

flash_message:
create: Le contenu "%name%" a été créé avec succès.
update: Le contenu "%name%" a été mis à jour avec succès.
delete: Le contenu "%name%" a été supprimé avec succès.


menu: menu:
dashboard: Tableau de bord dashboard: Tableau de bord
page: Pages page: Pages
user:
label: Utilisateurs
childs:
index: Liste
account:
label: Mon compte
childs:
profile: Informations personnelles
password: Mot de passe
user: Utilisateurs
user_index: Liste
account: Mon compte
account_profile: Informations personnelles
account_password: Mot de passe


title: title:
dashboard: Tableau de bord dashboard: Tableau de bord
profile: Mes informations personnelles profile: Mes informations personnelles
change_password: Changer de mot de passe change_password: Changer de mot de passe


action:
create: Créer
edit: Éditer
save: Sauvegarder
sort: Ordonner
delete: Supprimer
index_children: Afficher les enfants
index_parent: Retour au parent
back_index: Retour à la liste
save_and_return: Sauvegarder les modifications
save_and_continue: Sauvegarder et continuer l'édition
save_and_add_another: Créer et ajouter un nouvel élément

flash_message:
create: Le contenu "%name%" a été créé avec succès.
update: Le contenu "%name%" a été mis à jour avec succès.
delete: Le contenu "%name%" a été supprimé avec succès.
sort: Position modifiée

entity: entity:
user:
User:
label: Utilisateur label: Utilisateur
label_plurial: Utilisateurs label_plurial: Utilisateurs
fields: fields:
firstname: Prénom firstname: Prénom
lastname: Nom lastname: Nom
page:
Page:
label: Page label: Page
label_plurial: Pages label_plurial: Pages
default: default:
file: Fichier file: Fichier
status: Statut status: Statut
email: Email email: Email
metaTitle: Meta title
metaTitle_help: Affiché dans les résultats de recherche Google
metaDescription: Meta description
metaDescription_help: Affiché dans les résultats de recherche Google
oldUrls: Anciennes urls
devAlias: Alias
gallery: Galerie

panels: panels:
general: Général general: Général
configuration: Configuration configuration: Configuration
gallery: Galerie gallery: Galerie
seo: Référencement seo: Référencement


action:
save: Sauvegarder

form: form:
change_password:
current_password: Mot de passe actuel
new_password: Nouveau mot de passe
new_password_repeat: Nouveau mot de passe (confirmer)
account_profile:
message:
success: Votre profil a bien été modifié
account_password:
field:
current_password: Mot de passe actuel
new_password: Nouveau mot de passe
new_password_repeat: Nouveau mot de passe (confirmer)
message:
success: Votre mot de passe a bien été modifié
invalid_passwords: Les deux mots de passe ne correspondent pas.

+ 6
- 4
Resources/views/adminlte/crud/_form.html.twig View File



{% block configured_stylesheets %} {% block configured_stylesheets %}
{{ parent() }} {{ parent() }}
{% for css_asset in form.vars.ea_crud_form.assets.cssFiles %}

{% for css_asset in form.vars.ea_crud_form.assets.cssAssets %}
<link rel="stylesheet" href="{{ asset(css_asset) }}"> <link rel="stylesheet" href="{{ asset(css_asset) }}">
{% endfor %} {% endfor %}


{% for webpack_encore_entry in form.vars.ea_crud_form.assets.webpackEncoreEntries %}
{% for webpack_encore_entry in form.vars.ea_crud_form.assets.webpackEncoreAssets %}
{{ ea_call_function_if_exists('encore_entry_link_tags', webpack_encore_entry) }} {{ ea_call_function_if_exists('encore_entry_link_tags', webpack_encore_entry) }}
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}


{% block configured_javascripts %} {% block configured_javascripts %}
{{ parent() }} {{ parent() }}
{% for js_asset in form.vars.ea_crud_form.assets.jsFiles %}

{% for js_asset in form.vars.ea_crud_form.assets.jsAssets %}
<script src="{{ asset(js_asset) }}"></script> <script src="{{ asset(js_asset) }}"></script>
{% endfor %} {% endfor %}


{% for webpack_encore_entry in form.vars.ea_crud_form.assets.webpackEncoreEntries %}
{% for webpack_encore_entry in form.vars.ea_crud_form.assets.webpackEncoreAssets %}
{{ ea_call_function_if_exists('encore_entry_script_tags', webpack_encore_entry) }} {{ ea_call_function_if_exists('encore_entry_script_tags', webpack_encore_entry) }}
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}

+ 6
- 5
Resources/views/adminlte/crud/action/translatable.html.twig View File

{% for _locale in app_locales %} {% for _locale in app_locales %}
<a class="{{ isIncludedInDropdown|default(false) ? 'dropdown-item' }} {{ action.cssClass }}" <a class="{{ isIncludedInDropdown|default(false) ? 'dropdown-item' }} {{ action.cssClass }}"
href="{{ action.linkUrl }}&_locale={{ _locale }}" href="{{ action.linkUrl }}&_locale={{ _locale }}"
{% for name, value in action.htmlAttributes %}{{ name }}="{{ value|e('html_attr') }}" {% endfor %}>
{%- if action.icon %}<i class="action-icon {{ action.icon }}"></i> {% endif -%}
{%- if action.label is not empty -%}{{ action.label }} {{ _locale }}{%- endif -%}
{% for name, value in action.htmlAttributes %}{{ name }}="{{ value|e('html_attr') }}" {% endfor %}>
{%- if action.icon %}<i class="action-icon {{ action.icon }}"></i> {% endif -%}
{%- if action.label is not empty -%}{{ action.label }} {%- endif -%}
{{ _locale }}
</a> </a>
{% endfor %} {% endfor %}
{% elseif 'button' == action.htmlElement %} {% elseif 'button' == action.htmlElement %}
<button class="{{ action.cssClass }}" {% for name, value in action.htmlAttributes %}{{ name }}="{{ value|e('html_attr') }}" {% endfor %}> <button class="{{ action.cssClass }}" {% for name, value in action.htmlAttributes %}{{ name }}="{{ value|e('html_attr') }}" {% endfor %}>
<span class="btn-label">
<span class="btn-label">
{%- if action.icon %}<i class="action-icon {{ action.icon }}"></i> {% endif -%} {%- if action.icon %}<i class="action-icon {{ action.icon }}"></i> {% endif -%}
{%- if action.label is not empty -%}{{ action.label }}{%- endif -%}
{%- if action.label is not empty -%}{{ action.label }}{%- endif -%}
</span> </span>
</button> </button>
{% endif %} {% endif %}

+ 27
- 10
Resources/views/adminlte/crud/form_theme.html.twig View File

{% set has_append_html = ea.field.append_html|default(null) is not null %} {% set has_append_html = ea.field.append_html|default(null) is not null %}
{% set has_input_groups = has_prepend_html or has_append_html %} {% set has_input_groups = has_prepend_html or has_append_html %}


{% if has_input_groups %}<div class="input-group">{% endif %}
{% if has_input_groups %}
<div class="input-group">{% endif %}
{% if has_prepend_html %} {% if has_prepend_html %}
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text">{{ ea.field.prepend_html|raw }}</span> <span class="input-group-text">{{ ea.field.prepend_html|raw }}</span>
<div class="nullable-control"> <div class="nullable-control">
<label> <label>
<input type="checkbox" {% if data is null %}checked="checked"{% endif %}> <input type="checkbox" {% if data is null %}checked="checked"{% endif %}>
{{ 'label.nullable_field'|trans({}, 'EasyAdminBundle')}}
{{ 'label.nullable_field'|trans({}, 'EasyAdminBundle') }}
</label> </label>
</div> </div>
{% endif %} {% endif %}


{% block file_manager_widget %} {% block file_manager_widget %}


<div class="lc-filemanager row">
<div class="col-md-3 col-xs-12 form-group">
{% if form.vars.ea_crud_form.ea_field is not null %}

{% set managerDir = form.vars.ea_crud_form.ea_field.customOptions.get('managerDir') %}
{% set type = form.vars.ea_crud_form.ea_field.customOptions.get('type') %}

<div class="lc-filemanager row">
{% if type == 'image' %}
<div class="col-md-3 col-xs-12 form-group">
<div class="lc-filemenager-preview card"> <div class="lc-filemenager-preview card">
<div class="no-image"> <div class="no-image">
<i class="fa fa-image"></i> <i class="fa fa-image"></i>
</div> </div>
<img src="{{ form.path.vars.value }}" id="{{ form.path.vars.id }}_preview" alt="" class="card-img-top"> <img src="{{ form.path.vars.value }}" id="{{ form.path.vars.id }}_preview" alt="" class="card-img-top">
</div> </div>
</div>
</div>
{% else %}
<div class="callout callout-success">
<h5><i class="fa fa-file-alt"></i>
<span id="{{ form.path.vars.id }}_preview_text">{{ form.path.vars.value }}</span>
</h5>
</div>
{% endif %}

<div class="col-12"> <div class="col-12">
<div class="input-group"> <div class="input-group">
<div class="input-group-prepend"> <div class="input-group-prepend">
{% endif %} {% endif %}
<button type="button" class="btn btn-primary lc-filemanager-open" data-id="{{ form.path.vars.id }}" <button type="button" class="btn btn-primary lc-filemanager-open" data-id="{{ form.path.vars.id }}"
data-toggle="tooltip" title="Sélectionner un fichier" data-toggle="tooltip" title="Sélectionner un fichier"
data-target="{{ path('file_manager', {module:1, conf:'default'})|raw }}">
data-target="{{ path('file_manager', {module:1, conf: managerDir})|raw }}">
<i class="fa fa-folder-open"></i> <i class="fa fa-folder-open"></i>
</button> </button>
</div> </div>
{{ form_rest(form) }} {{ form_rest(form) }}
</div> </div>
</div> </div>
</div>
</div>
{% endif %}
{% endblock file_manager_widget %} {% endblock file_manager_widget %}


{% block checkbox_radio_label -%} {% block checkbox_radio_label -%}
{#- Do not display the label if widget is not defined in order to prevent double label rendering -#}
{#- Do not display the label if widget is not defined in order to prevent double label rendering -#}
{%- if widget is defined -%} {%- if widget is defined -%}
{% set is_parent_custom = parent_label_class is defined and ('checkbox-custom' in parent_label_class or 'radio-custom' in parent_label_class or 'switch-custom' in parent_label_class) %} {% set is_parent_custom = parent_label_class is defined and ('checkbox-custom' in parent_label_class or 'radio-custom' in parent_label_class or 'switch-custom' in parent_label_class) %}
{% set is_custom = label_attr.class is defined and ('checkbox-custom' in label_attr.class or 'radio-custom' in label_attr.class or 'switch-custom' in label_attr.class) %} {% set is_custom = label_attr.class is defined and ('checkbox-custom' in label_attr.class or 'radio-custom' in label_attr.class or 'switch-custom' in label_attr.class) %}
{% for panel_name, panel_config in ea_crud_form.form_panels|filter(panel_config => not panel_config.form_tab or panel_config.form_tab == tab_name) %} {% for panel_name, panel_config in ea_crud_form.form_panels|filter(panel_config => not panel_config.form_tab or panel_config.form_tab == tab_name) %}
{% set panel_has_header = panel_config.label|default(false) or panel_config.icon|default(false) %} {% set panel_has_header = panel_config.label|default(false) or panel_config.icon|default(false) %}
<li class="nav-item"> <li class="nav-item">
<a href="#panel-{{ panel_name }} " class="nav-link {{ panel_name == 1 ? 'active' }}" data-toggle="tab" role="tab"
<a href="#panel-{{ panel_name }} " class="nav-link {{ panel_name == 1 ? 'active' }}"
data-toggle="tab" role="tab"
aria-controls="panel-{{ panel_name }}"> aria-controls="panel-{{ panel_name }}">
{{ panel_config.label|lc_trans_admin_panel(ea.getEntity().getFqcn()) }} {{ panel_config.label|lc_trans_admin_panel(ea.getEntity().getFqcn()) }}
<i class="fa fa-exclamation-circle invalid-form"></i>
<i class="fa fa-exclamation-circle invalid-form"></i>
</a> </a>
</li> </li>
{% endfor %} {% endfor %}

+ 4
- 2
Resources/views/adminlte/layout.html.twig View File

<link rel="stylesheet" href="{{ asset(css_asset) }}"> <link rel="stylesheet" href="{{ asset(css_asset) }}">
{% endfor %} {% endfor %}


{% for webpack_encore_entry in ea.assets.webpackEncoreEntries ?? [] %}

{% for webpack_encore_entry in ea.assets.webpackEncoreAssets ?? [] %}
{{ ea_call_function_if_exists('encore_entry_link_tags', webpack_encore_entry) }} {{ ea_call_function_if_exists('encore_entry_link_tags', webpack_encore_entry) }}
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}


{% block body %} {% block body %}
<body id="{% block body_id %}{% endblock %}" class="sidebar-mini layout-fixed {% block body_class %}{% endblock %}"> <body id="{% block body_id %}{% endblock %}" class="sidebar-mini layout-fixed {% block body_class %}{% endblock %}">

{% block javascript_page_layout %} {% block javascript_page_layout %}
<script> <script>
document.body.classList.add( document.body.classList.add(
<script src="{{ asset(js_asset) }}"></script> <script src="{{ asset(js_asset) }}"></script>
{% endfor %} {% endfor %}


{% for webpack_encore_entry in ea.assets.webpackEncoreEntries ?? [] %}
{% for webpack_encore_entry in ea.assets.webpackEncoreAssets ?? [] %}
{{ ea_call_function_if_exists('encore_entry_script_tags', webpack_encore_entry, null, '_default', {'defer': false}) }} {{ ea_call_function_if_exists('encore_entry_script_tags', webpack_encore_entry, null, '_default', {'defer': false}) }}
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}

+ 32
- 18
Translation/TranslatorAdmin.php View File

$this->translator = $translator; $this->translator = $translator;
} }


public function transAction($action)
{
return $this->trans('action.' . $action);
}

public function transMenu($menu)
{
return $this->trans('menu.' . $menu);
}

public function transFlashMessage($name)
{
return $this->trans('flash_message.' . $name);
}

public function transField($fieldName, $entityClass): string public function transField($fieldName, $entityClass): string
{ {
return $this->transEntityThenDefault( return $this->transEntityThenDefault(
{ {
$entityName = $this->getEntityName($entityClass); $entityName = $this->getEntityName($entityClass);


$paramsTranslation = [] ;
$paramsTranslation = [];


if($entityName) {
$baseIdEntityLabel = 'entity.' . $entityName ;
if ($entityName) {
$baseIdEntityLabel = 'entity.' . $entityName;
$paramsTranslation = [ $paramsTranslation = [
'%label%' => $this->trans($baseIdEntityLabel . '.label'), '%label%' => $this->trans($baseIdEntityLabel . '.label'),
'%label_plurial%' => $this->trans($baseIdEntityLabel . '.label_plurial'), '%label_plurial%' => $this->trans($baseIdEntityLabel . '.label_plurial'),
] ;
];
} }


if (isset($params['id'])) { if (isset($params['id'])) {


private function buildTransIdField($fieldName, $entityClass, $default = false): string private function buildTransIdField($fieldName, $entityClass, $default = false): string
{ {
if ($default) {
$entityName = 'default';
} else {
$entityName = $this->getEntityName($entityClass);
}

return 'entity.' . $entityName . '.fields.' . $fieldName;
return $this->buildTransIdEntitySection($fieldName, $entityClass, 'fields', $default);
} }


private function buildTransIdPanel($panelName, $entityClass, $default = false): string private function buildTransIdPanel($panelName, $entityClass, $default = false): string
{
return $this->buildTransIdEntitySection($panelName, $entityClass, 'panels', $default);
}

private function buildTransIdEntitySection($name, $entityClass, $entitySection, $default): string
{ {
if ($default) { if ($default) {
$entityName = 'default'; $entityName = 'default';
$entityName = $this->getEntityName($entityClass); $entityName = $this->getEntityName($entityClass);
} }


return 'entity.' . $entityName . '.panels.' . $panelName;
return 'entity.' . $entityName . '.' . $entitySection . '.' . $name;
} }


private function trans($id, $params = [], $domain = self::DOMAIN): string
public function trans($id, $params = [], $domain = self::DOMAIN): string
{ {
return $this->translator->trans($id, $params, $domain); return $this->translator->trans($id, $params, $domain);
} }


private function getEntityName($entityClass): string private function getEntityName($entityClass): string
{ {
if(is_object($entityClass)) {
$entityClass = get_class($entityClass) ;
if (is_object($entityClass)) {
$entityClass = get_class($entityClass);
} }


if(is_string($entityClass)) {
if (is_string($entityClass)) {
$entityNameExplode = explode('\\', $entityClass); $entityNameExplode = explode('\\', $entityClass);
return strtolower($entityNameExplode[count($entityNameExplode) - 1]);
return $entityNameExplode[count($entityNameExplode) - 1];
} }


return 'default' ;
return 'default';
} }
} }



+ 7
- 1
Twig/TwigExtension.php View File

new TwigFilter('lc_trans_admin_panel', [$this, 'lcTransAdminPanel']), new TwigFilter('lc_trans_admin_panel', [$this, 'lcTransAdminPanel']),
new TwigFilter('lc_trans_admin_menu', [$this, 'lcTransAdminMenu']), new TwigFilter('lc_trans_admin_menu', [$this, 'lcTransAdminMenu']),
new TwigFilter('lc_trans_admin_title', [$this, 'lcTransAdminTitle']), new TwigFilter('lc_trans_admin_title', [$this, 'lcTransAdminTitle']),
new TwigFilter('lc_trans_admin_action', [$this, 'lcTransAdminAction']),
]; ];
} }




public function lcTransAdminMenu($menuName) public function lcTransAdminMenu($menuName)
{ {
return $this->translator->trans('menu.' . $menuName, [], 'admin');;
return $this->translatorAdmin->transMenu($menuName);;
}

public function lcTransAdminAction($actionName)
{
return $this->translatorAdmin->transAction($actionName);;
} }


public function lcTransAdminTitle($pageName, $entityClass = null, $params = []) public function lcTransAdminTitle($pageName, $entityClass = null, $params = [])

Loading…
Cancel
Save