@@ -205,6 +205,7 @@ abstract class AbstractCrudController extends EaAbstractCrudController | |||
public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore | |||
{ | |||
// fields sur la page index | |||
if (Crud::PAGE_INDEX === $responseParameters->get('pageName')) { | |||
$responseParameters->set('fields', $this->configureFields('index')); | |||
} | |||
@@ -244,7 +245,7 @@ abstract class AbstractCrudController extends EaAbstractCrudController | |||
{ | |||
if ($this->isInstanceOf(SortableInterface::class)) { | |||
$seoPanel = [ | |||
FormField::addPanel('Seo'), | |||
FormField::addPanel('seo'), | |||
TextField::new('metaTitle')->setLabel('Meta Title')->setHelp( | |||
'Affiché dans les résultats de recherche Google' | |||
)->hideOnIndex(), | |||
@@ -260,7 +261,7 @@ abstract class AbstractCrudController extends EaAbstractCrudController | |||
if ($this->isInstanceOf(DevAliasInterface::class)) { | |||
$confPanel = [ | |||
FormField::addPanel('Conf'), | |||
FormField::addPanel('configuration'), | |||
TextField::new('devAlias')->hideOnIndex(), | |||
]; | |||
} | |||
@@ -306,7 +307,6 @@ abstract class AbstractCrudController extends EaAbstractCrudController | |||
->getForm(); | |||
$entityManager = $this->getDoctrine()->getManagerForClass($this->getEntityFqcn()); | |||
dump($entityManager); | |||
$repository = $entityManager->getRepository($this->getEntityFqcn()); | |||
$sortableForm->handleRequest($context->getRequest()); |
@@ -30,7 +30,7 @@ class DashboardController extends AbstractDashboardController | |||
// 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'); | |||
->setTranslationDomain('admin'); | |||
} | |||
public function configureAssets(): Assets |
@@ -65,6 +65,7 @@ class UserController extends AbstractController | |||
return $this->render( | |||
'@LcSov/user/change_password.html.twig', | |||
[ | |||
'entity_class' => User::class, | |||
'form' => $form->createView() | |||
] | |||
); |
@@ -29,22 +29,22 @@ class EasyAdminEventSubscriber implements EventSubscriberInterface | |||
public function flashMessageAfterPersist(AfterEntityPersistedEvent $event): void | |||
{ | |||
$this->session->getFlashBag()->add('success', new TranslatableMessage('content_admin.flash_message.create', [ | |||
$this->session->getFlashBag()->add('success', new TranslatableMessage('flash_message.create', [ | |||
'%name%' => (string) $event->getEntityInstance(), | |||
], 'admin')); | |||
])); | |||
} | |||
public function flashMessageAfterUpdate(AfterEntityUpdatedEvent $event): void | |||
{ | |||
$this->session->getFlashBag()->add('success', new TranslatableMessage('content_admin.flash_message.update', [ | |||
$this->session->getFlashBag()->add('success', new TranslatableMessage('flash_message.update', [ | |||
'%name%' => (string) $event->getEntityInstance(), | |||
], 'admin')); | |||
])); | |||
} | |||
public function flashMessageAfterDelete(AfterEntityDeletedEvent $event): void | |||
{ | |||
$this->session->getFlashBag()->add('success', new TranslatableMessage('content_admin.flash_message.delete', [ | |||
$this->session->getFlashBag()->add('success', new TranslatableMessage('flash_message.delete', [ | |||
'%name%' => (string) $event->getEntityInstance(), | |||
], 'admin')); | |||
])); | |||
} | |||
} |
@@ -9,7 +9,6 @@ $(document).ready(function () { | |||
function initCollectionWidget() { | |||
Tools.log('czefe'); | |||
$('.field-collection[data-prototype]').each(function (i, collectionWidget) { | |||
setCollectionWidgetSortable($(collectionWidget)); | |||
@@ -65,9 +64,7 @@ function getNumItems($collectionWidget) { | |||
} | |||
function reindexKeyCollectionWidget($collectionWidget) { | |||
Tools.log('ncncnc'); | |||
if ($collectionWidget.data('reindex-key')) { | |||
Tools.log('ncncnc'); | |||
$collectionWidget.find('.field-collection-item').each(function (i, item) { | |||
$(item).find('input,textarea').each(function (y, field) { | |||
let $field = $(field); |
@@ -1,5 +1,34 @@ | |||
content_admin: | |||
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. | |||
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. | |||
form: | |||
title: | |||
edit: Modifier "%name%" | |||
new: Ajouter "%name%" | |||
menu: | |||
dashboard: Tableau de bord | |||
account: | |||
label: Mon compte | |||
childs: | |||
profile: Informations personnelles | |||
password: Mot de passe | |||
entity: | |||
default: | |||
fields: | |||
title: Titre | |||
position: Position | |||
position_help: Position help | |||
description: Description | |||
description_help: Description help | |||
file: Fichier | |||
status: Statut | |||
panels: | |||
general: Général | |||
configuration: Configuration | |||
gallery: Galerie | |||
seo: Référencement |
@@ -1,5 +1,6 @@ | |||
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} | |||
{% macro render_menu_item(item, is_sub_item = false) %} | |||
{% if item.isMenuSection %} | |||
{% if item.icon is not empty %} | |||
<i class="fa fa-{{ item.icon }}"></i> | |||
@@ -11,7 +12,7 @@ | |||
{% if item.icon is not empty %} | |||
<i class="far fa-{{ item.icon }} nav-icon"></i> | |||
{% endif %} | |||
<p>{{ item.label|raw }}</p> | |||
<p>{{ item.label|lc_trans_admin_menu }}</p> | |||
{% if item.hasSubItems %}<i class="right fas fa-angle-left"></i>{% endif %} | |||
</a> | |||
{% endif %} |
@@ -7,11 +7,7 @@ | |||
{% block body_class 'ea-edit ea-edit-' ~ entity.name %} | |||
{% block content_title %} | |||
{%- apply spaceless -%} | |||
{{ ea.crud.customPageTitle is null | |||
? (ea.crud.defaultPageTitle|trans(ea.i18n.translationParameters, 'EasyAdminBundle'))|raw | |||
: ea.crud.customPageTitle|trans(ea.i18n.translationParameters)|raw }} | |||
{%- endapply -%} | |||
{{ 'edit'|lc_trans_admin_title(ea.getEntity().getFqcn()) }} | |||
{% endblock %} | |||
{% block delete_form %} |
@@ -1,6 +1,86 @@ | |||
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} | |||
{% use '@EasyAdmin/crud/form_theme.html.twig' %} | |||
{% block form_row %} | |||
{% set row_attr = row_attr|merge({ | |||
class: row_attr.class|default('') ~ ' form-group' | |||
}) %} | |||
<div {% with { attr: row_attr } %}{{ block('attributes') }}{% endwith %}> | |||
{{- form_label(form) -}} | |||
<div class="form-widget"> | |||
{% set has_prepend_html = ea.field.prepend_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 %} | |||
{% if has_input_groups %}<div class="input-group">{% endif %} | |||
{% if has_prepend_html %} | |||
<div class="input-group-prepend"> | |||
<span class="input-group-text">{{ ea.field.prepend_html|raw }}</span> | |||
</div> | |||
{% endif %} | |||
{{ form_widget(form) }} | |||
{% if has_append_html %} | |||
<div class="input-group-append"> | |||
<span class="input-group-text">{{ ea.field.append_html|raw }}</span> | |||
</div> | |||
{% endif %} | |||
{% if has_input_groups %}</div>{% endif %} | |||
{% set nullable_fields_fqcn = [ | |||
'EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField', | |||
'EasyCorp\Bundle\EasyAdminBundle\Field\DateField', | |||
'EasyCorp\Bundle\EasyAdminBundle\Field\TimeField', | |||
] %} | |||
{% if form.vars.ea_crud_form.ea_field.fieldFqcn|default(false) in nullable_fields_fqcn and ea.field.nullable|default(false) %} | |||
<div class="nullable-control"> | |||
<label> | |||
<input type="checkbox" {% if data is null %}checked="checked"{% endif %}> | |||
{{ 'label.nullable_field'|trans({}, 'EasyAdminBundle')}} | |||
</label> | |||
</div> | |||
{% endif %} | |||
{% set help_message = name|lc_trans_admin_field(ea.getEntity().getFqcn(), true) %} | |||
{% if help_message != '' %} | |||
<small class="form-help">{{ help_message }}</small> | |||
{% endif %} | |||
{{- form_errors(form) -}} | |||
</div> | |||
</div> | |||
{% endblock form_row %} | |||
{% block form_label -%} | |||
{% if label is same as(false) -%} | |||
<label>{# the empty <label> is needed to not break the form design #}</label> | |||
{%- else -%} | |||
{%- if compound is defined and compound -%} | |||
{%- set element = 'legend' -%} | |||
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-label')|trim}) -%} | |||
{%- else -%} | |||
{%- set label_attr = label_attr|merge({for: id, class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%} | |||
{%- endif -%} | |||
{% if required -%} | |||
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %} | |||
{%- endif -%} | |||
{% if label is empty -%} | |||
{%- if label_format is not empty -%} | |||
{% set label = label_format|replace({ | |||
'%name%': name, | |||
'%id%': id, | |||
}) %} | |||
{%- else -%} | |||
{# {% set label = name|humanize %} #} | |||
{%- endif -%} | |||
{%- endif -%} | |||
<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ (translation_domain is same as(false)) ? label : label|lower|lc_trans_admin_field(ea.getEntity().getFqcn()) }}</{{ element|default('label') }}> | |||
{%- endif -%} | |||
{%- endblock form_label %} | |||
{% block gallery_manager_row %} | |||
{{ block('collection_row') }} | |||
{% endblock gallery_manager_row %} | |||
@@ -9,7 +89,6 @@ | |||
{{ block('collection_widget') }} | |||
{% endblock gallery_manager_widget %} | |||
{% block collection_row %} | |||
{% if prototype is defined and not prototype.rendered %} | |||
{% set row_attr = row_attr|merge({ 'data-prototype': form_row(prototype) }) %} | |||
@@ -145,6 +224,7 @@ | |||
{{ name|lc_trad(easyadmin['entity']['name'], 'field') }} | |||
{% else %} #} | |||
{{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain))|raw -}} | |||
{# {% endif %} #} | |||
{{- form_errors(form) -}} | |||
</label> | |||
@@ -156,6 +236,7 @@ | |||
{{ parent() }} | |||
{% if ea_crud_form.form_panels is defined %} | |||
<div class="card card-outline"> | |||
<div class="card-header p-0 border-bottom-0"> | |||
<ul id="nav-params" class="nav nav-pills" role="navigation"> | |||
@@ -164,7 +245,7 @@ | |||
<li class="nav-item"> | |||
<a href="#panel-{{ panel_name }} " class="nav-link {{ panel_name == 1 ? 'active' }}" data-toggle="tab" role="tab" | |||
aria-controls="panel-{{ panel_name }}"> | |||
{{ panel_config.label|raw }} | |||
{{ panel_config.label|lc_trans_admin_panel(ea.getEntity().getFqcn()) }} | |||
<i class="fa fa-exclamation-circle invalid-form"></i> | |||
</a> | |||
</li> |
@@ -9,10 +9,7 @@ | |||
{% block body_class 'index' ~ (entities|length > 0 ? ' index-' ~ entities|first.name : '') %} | |||
{% block content_title %} | |||
{%- apply spaceless -%} | |||
{% set default_title = ea.crud.defaultPageTitle('index')|trans(ea.i18n.translationParameters, 'EasyAdminBundle') %} | |||
{{ ea.crud.customPageTitle is null ? default_title|raw : ea.crud.customPageTitle('index')|trans(ea.i18n.translationParameters)|raw }} | |||
{%- endapply -%} | |||
{{ 'index'|lc_trans_admin_title(ea.getEntity().getFqcn()) }} | |||
{% endblock %} | |||
{% block content_breadcrumb %} | |||
@@ -25,6 +22,7 @@ | |||
{% endblock page_actions %} | |||
{% block main %} | |||
{# sort can be multiple; let's consider the sorting field the first one #} | |||
{% set sort_field_name = app.request.get('sort')|keys|first %} | |||
{% set sort_order = app.request.get('sort')|first %} | |||
@@ -94,7 +92,7 @@ | |||
class="fa fa-fw {{ column_icon }}"></i> | |||
</a> | |||
{% else %} | |||
<span>{{ field.label ? field.label|raw : field.getProperty|raw }}</span> | |||
<span>{{ field.getProperty|lc_trans_admin_field(ea.getEntity().getFqcn()) }}</span> | |||
{% endif %} | |||
</th> | |||
{% endif %} | |||
@@ -208,6 +206,7 @@ | |||
{{ parent() }} | |||
<script type="text/javascript"> | |||
$(function () { | |||
/* $('.action-delete').on('click', function (e) { |
@@ -7,10 +7,7 @@ | |||
{% block body_class 'ea-new ea-new-' ~ entity.name %} | |||
{% block content_title %} | |||
{%- apply spaceless -%} | |||
{% set default_title = ea.crud.defaultPageTitle('new')|trans(ea.i18n.translationParameters, 'EasyAdminBundle') %} | |||
{{ ea.crud.customPageTitle is null ? default_title|raw : ea.crud.customPageTitle('new')|trans(ea.i18n.translationParameters)|raw }} | |||
{%- endapply -%} | |||
{{ 'new'|lc_trans_admin_title(ea.getEntity().getFqcn()) }} | |||
{% endblock %} | |||
@@ -165,7 +165,7 @@ | |||
{% endfor %} | |||
{% for webpack_encore_entry in ea.assets.webpackEncoreEntries ?? [] %} | |||
{{ ea_call_function_if_exists('encore_entry_script_tags', webpack_encore_entry) }} | |||
{{ ea_call_function_if_exists('encore_entry_script_tags', webpack_encore_entry, null, '_default', {'defer': false}) }} | |||
{% endfor %} | |||
{% endblock %} | |||
@@ -182,13 +182,15 @@ | |||
{% if app.session is not null and app.session.started %} | |||
{% set flash_messages = app.session.flashbag.all %} | |||
{% if flash_messages|length > 0 %} | |||
{% for label, messages in flash_messages %} | |||
{% for message in messages %} | |||
<script type="text/javascript"> | |||
Notification.add("{{ label }}", "{{ message|trans|raw|replace({'"': '\"'}) }}") ; | |||
</script> | |||
<script type="text/javascript"> | |||
$(document).ready(function() { | |||
{% for label, messages in flash_messages %} | |||
{% for message in messages %} | |||
Notification.add("{{ label }}", "{{ message|trans|raw|replace({'"': '\"'}) }}"); | |||
{% endfor %} | |||
{% endfor %} | |||
{% endfor %} | |||
}); | |||
</script> | |||
{% endif %} | |||
{% endif %} | |||
@@ -3,105 +3,207 @@ | |||
namespace Lc\SovBundle\Twig; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | |||
use Liip\ImagineBundle\Imagine\Cache\CacheManager; | |||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||
use Symfony\Component\HttpFoundation\RequestStack; | |||
use Symfony\Component\HttpKernel\KernelInterface; | |||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | |||
use Symfony\Contracts\Translation\TranslatorInterface; | |||
use Twig\Extension\AbstractExtension; | |||
use Twig\TwigFilter; | |||
use Twig\TwigFunction; | |||
class TwigExtension extends AbstractExtension | |||
{ | |||
protected $em; | |||
protected $kernel; | |||
protected $parameterBag; | |||
protected $cacheManager; | |||
protected $requestStack; | |||
protected $router; | |||
public function __construct(KernelInterface $kernel, ParameterBagInterface $parameterBag, CacheManager $cacheManager, EntityManagerInterface $entityManager, RequestStack $requestStack,UrlGeneratorInterface $router) | |||
{ | |||
$this->kernel = $kernel; | |||
$this->parameterBag = $parameterBag; | |||
$this->cacheManager = $cacheManager; | |||
$this->em = $entityManager; | |||
$this->requestStack = $requestStack; | |||
$this->router = $router; | |||
protected $em; | |||
protected $kernel; | |||
protected $parameterBag; | |||
protected $cacheManager; | |||
protected $requestStack; | |||
protected $router; | |||
protected $translator; | |||
public function __construct( | |||
KernelInterface $kernel, | |||
ParameterBagInterface $parameterBag, | |||
CacheManager $cacheManager, | |||
EntityManagerInterface $entityManager, | |||
RequestStack $requestStack, | |||
UrlGeneratorInterface $router, | |||
TranslatorInterface $translator | |||
) { | |||
$this->kernel = $kernel; | |||
$this->parameterBag = $parameterBag; | |||
$this->cacheManager = $cacheManager; | |||
$this->em = $entityManager; | |||
$this->requestStack = $requestStack; | |||
$this->router = $router; | |||
$this->translator = $translator; | |||
} | |||
public function getFunctions() | |||
{ | |||
return array( | |||
new TwigFunction('lc_liip', [$this, 'lcLiip']), | |||
new TwigFunction('homepage_route', [$this, 'homepageRoute']), | |||
new TwigFunction('page_by_dev_alias', [$this, 'getPageByDevAlias']), | |||
new TwigFunction('translated_urls', [$this, 'getTranslatedUrls']) | |||
); | |||
} | |||
public function getFilters() | |||
{ | |||
return [ | |||
new TwigFilter('lc_cache', [$this, 'lcCache']), | |||
new TwigFilter('lc_trans_admin_field', [$this, 'lcTransAdminField']), | |||
new TwigFilter('lc_trans_admin_panel', [$this, 'lcTransAdminPanel']), | |||
new TwigFilter('lc_trans_admin_menu', [$this, 'lcTransAdminMenu']), | |||
new TwigFilter('lc_trans_admin_title', [$this, 'lcTransAdminTitle']), | |||
]; | |||
} | |||
public function lcCache($file) | |||
{ | |||
$cacheTime = filemtime($this->kernel->getProjectDir() . '/public' . $file); | |||
if ($cacheTime) { | |||
return $file . '?c=' . $cacheTime; | |||
} else { | |||
return $file . "?c=0"; | |||
} | |||
} | |||
public function getFunctions() | |||
{ | |||
return array( | |||
new TwigFunction('lc_liip', [$this, 'lcLiip']), | |||
new TwigFunction('homepage_route', [$this, 'homepageRoute']), | |||
new TwigFunction('page_by_dev_alias', [$this, 'getPageByDevAlias']), | |||
new TwigFunction('translated_urls', [$this, 'getTranslatedUrls']) | |||
); | |||
public function lcTransAdminField($fieldName, $entityClass, $isHelp = false) | |||
{ | |||
if ($isHelp) { | |||
$fieldName = $fieldName . '_help'; | |||
} | |||
$entityName = $this->getEntityName($entityClass) ; | |||
public function getFilters() | |||
{ | |||
return [ | |||
new TwigFilter('lc_cache', [$this, 'lcCache']), | |||
]; | |||
} | |||
$entityLabel = 'entity.' . $entityName . '.fields.' . $fieldName; | |||
$translatedLabel = $this->translator->trans($entityLabel, [], 'admin'); | |||
if ($translatedLabel == $entityLabel) { | |||
$defaultLabel = 'entity.default.fields.' . $fieldName; | |||
$translatedLabel = $this->translator->trans($defaultLabel, [], 'admin'); | |||
public function lcCache($file) | |||
{ | |||
$cacheTime = filemtime($this->kernel->getProjectDir() . '/public' . $file); | |||
if ($cacheTime) { | |||
return $file . '?c=' . $cacheTime; | |||
if ($translatedLabel == $defaultLabel) { | |||
if ($isHelp) { | |||
$translatedLabel = ''; | |||
} else { | |||
return $file . "?c=0"; | |||
$translatedLabel = $entityLabel; | |||
} | |||
} | |||
} | |||
public function lcLiip($path, $thumb = 'tile', $default = 'default.jpg') | |||
{ | |||
if (substr($path, 0, 1) === '/') $path = substr($path, 1); | |||
return $translatedLabel; | |||
} | |||
if ($path) { | |||
$fileManagerFolder = substr($this->getFileManagerFolder(), 1) ; | |||
public function lcTransAdminPanel($panelName, $entityClass) | |||
{ | |||
$entityName = $this->getEntityName($entityClass) ; | |||
if (strpos($path, $fileManagerFolder) === false) { | |||
$path = $fileManagerFolder . '/' . $path; | |||
} | |||
$panelLabel = 'entity.' . $entityName . '.panels.' . $panelName; | |||
$translatedLabel = $this->translator->trans($panelLabel, [], 'admin'); | |||
if (file_exists($path)) { | |||
return $this->cacheManager->getBrowserPath($path, $thumb); | |||
} | |||
} | |||
if ($translatedLabel == $panelLabel) { | |||
$defaultLabel = 'entity.default.panels.' . $panelName; | |||
$translatedLabel = $this->translator->trans($defaultLabel, [], 'admin'); | |||
return $this->cacheManager->getBrowserPath($this->getFileManagerFolder() . '/' . $default, $thumb); | |||
if ($translatedLabel == $defaultLabel) { | |||
$translatedLabel = $panelLabel; | |||
} | |||
} | |||
function getTranslatedUrls() | |||
{ | |||
$ret = array(); | |||
$langs = $this->parameterBag->get('app.locales'); | |||
$currentRoute = $this->requestStack->getCurrentRequest()->get('_route'); | |||
return $translatedLabel; | |||
} | |||
$params = array_merge((array)$this->requestStack->getCurrentRequest()->get('_route_params'), $_GET); | |||
public function lcTransAdminMenu($menuName) | |||
{ | |||
$menuLabel = 'menu.'.$menuName; | |||
$translatedLabel = $this->translator->trans($menuLabel, [], 'admin'); | |||
if ($currentRoute) { | |||
foreach($langs as $lg) { | |||
$ret[$lg] = $this->router->generate($currentRoute, array_merge($params, array('_locale'=>$lg))); | |||
} | |||
} | |||
return $translatedLabel ; | |||
} | |||
public function lcTransAdminTitle($pageName, $entityClass) | |||
{ | |||
$entityName = $this->getEntityName($entityClass) ; | |||
$translatedLabel = '' ; | |||
return $ret; | |||
if(Crud::PAGE_INDEX == $pageName) { | |||
$titleLabel = 'entity.'.$entityName.'.label_plurial' ; | |||
$translatedLabel = $this->translator->trans($titleLabel, [], 'admin'); | |||
} | |||
elseif(Crud::PAGE_EDIT == $pageName) { | |||
$entityLabel = 'entity.'.$entityName.'.label' ; | |||
$translatedEntityLabel = $this->translator->trans($entityLabel, [],'admin'); | |||
$translatedLabel = $this->translator->trans('form.title.edit', ['%name%' => $translatedEntityLabel], 'admin'); | |||
} | |||
elseif(Crud::PAGE_NEW == $pageName) { | |||
$entityLabel = 'entity.'.$entityName.'.label' ; | |||
$translatedEntityLabel = $this->translator->trans($entityLabel, [], 'admin'); | |||
$translatedLabel = $this->translator->trans('form.title.new', ['%name%' => $translatedEntityLabel], 'admin'); | |||
} | |||
return $translatedLabel ; | |||
} | |||
public function getFileManagerFolder() | |||
{ | |||
return $this->parameterBag->get('app.path_uploads'); | |||
public function getEntityName($entityClass) | |||
{ | |||
$entityNameExplode = explode('\\', $entityClass); | |||
$entityName = strtolower($entityNameExplode[count($entityNameExplode) - 1]); | |||
return $entityName ; | |||
} | |||
public function lcLiip($path, $thumb = 'tile', $default = 'default.jpg') | |||
{ | |||
if (substr($path, 0, 1) === '/') { | |||
$path = substr($path, 1); | |||
} | |||
public function homepageRoute(){ | |||
return $this->parameterBag->get('lc_sov.homepage_route'); | |||
if ($path) { | |||
$fileManagerFolder = substr($this->getFileManagerFolder(), 1); | |||
if (strpos($path, $fileManagerFolder) === false) { | |||
$path = $fileManagerFolder . '/' . $path; | |||
} | |||
if (file_exists($path)) { | |||
return $this->cacheManager->getBrowserPath($path, $thumb); | |||
} | |||
} | |||
return $this->cacheManager->getBrowserPath($this->getFileManagerFolder() . '/' . $default, $thumb); | |||
} | |||
function getTranslatedUrls() | |||
{ | |||
$ret = array(); | |||
$langs = $this->parameterBag->get('app.locales'); | |||
$currentRoute = $this->requestStack->getCurrentRequest()->get('_route'); | |||
$params = array_merge((array)$this->requestStack->getCurrentRequest()->get('_route_params'), $_GET); | |||
if ($currentRoute) { | |||
foreach ($langs as $lg) { | |||
$ret[$lg] = $this->router->generate($currentRoute, array_merge($params, array('_locale' => $lg))); | |||
} | |||
} | |||
return $ret; | |||
} | |||
public function getFileManagerFolder() | |||
{ | |||
return $this->parameterBag->get('app.path_uploads'); | |||
} | |||
public function homepageRoute() | |||
{ | |||
return $this->parameterBag->get('lc_sov.homepage_route'); | |||
} | |||
} |