use ControllerTrait; | use ControllerTrait; | ||||
/** | |||||
* @Route("/admin", name="app_admin_dashboard") | |||||
*/ | |||||
public function index(): Response | public function index(): Response | ||||
{ | { | ||||
return $this->render('@LcSov/adminlte/dashboard.html.twig'); | return $this->render('@LcSov/adminlte/dashboard.html.twig'); | ||||
return Dashboard::new() | return Dashboard::new() | ||||
// the name visible to end users | // the name visible to end users | ||||
->setTitle('LA CLIC !') | ->setTitle('LA CLIC !') | ||||
// you can include HTML contents too (e.g. to link to an image) | |||||
->setTitle('<img src="assets/img/'.$this->get('parameter_bag')->get('app.admin.logo').'" width="100px">') | |||||
// the path defined in this method is passed to the Twig asset() function | // the path defined in this method is passed to the Twig asset() function | ||||
->setFaviconPath('assets/img/frontend/favicon-pdl.png') | ->setFaviconPath('assets/img/frontend/favicon-pdl.png') | ||||
// the domain used by default is 'messages' | // the domain used by default is 'messages' |
public function show(Throwable $exception, DebugLoggerInterface $logger = null) | public function show(Throwable $exception, DebugLoggerInterface $logger = null) | ||||
{ | { | ||||
if ($this->getRequestStack()->getCurrentRequest()->getPathInfo() == "/admin") { | |||||
if (str_contains($this->getRequestStack()->getCurrentRequest(), "/admin")) { | |||||
return $this->render('@LcSov/exception/error.html.twig', [ | return $this->render('@LcSov/exception/error.html.twig', [ | ||||
"code" => $exception->getCode(), | "code" => $exception->getCode(), | ||||
"message" => $exception->getMessage() | "message" => $exception->getMessage() |
// the title visible above the login form (define this option only if you are | // the title visible above the login form (define this option only if you are | ||||
// rendering the login template in a regular Symfony controller; when rendering | // rendering the login template in a regular Symfony controller; when rendering | ||||
// it from an EasyAdmin Dashboard this is automatically set as the Dashboard title) | // it from an EasyAdmin Dashboard this is automatically set as the Dashboard title) | ||||
'page_title' => '<img src="assets/img/' . $this->get('parameter_bag')->get('app.admin.logo') . '" >', | |||||
'page_title' => '<img class="logo-admin" src="assets/img/' . $this->getParameter('app.admin.logo') . '" >', | |||||
// the string used to generate the CSRF token. If you don't define | // the string used to generate the CSRF token. If you don't define | ||||
// this parameter, the login form won't include a CSRF token | // this parameter, the login form won't include a CSRF token | ||||
'target_path' => $this->generateUrl('app_admin_dashboard'), | 'target_path' => $this->generateUrl('app_admin_dashboard'), | ||||
// the label displayed for the username form field (the |trans filter is applied to it) | // the label displayed for the username form field (the |trans filter is applied to it) | ||||
'username_label' => 'Your username', | |||||
'username_label' => 'Email', | |||||
// the label displayed for the password form field (the |trans filter is applied to it) | // the label displayed for the password form field (the |trans filter is applied to it) | ||||
'password_label' => 'Your password', | |||||
'password_label' => 'Mot de passe', | |||||
// the label displayed for the Sign In form button (the |trans filter is applied to it) | // the label displayed for the Sign In form button (the |trans filter is applied to it) | ||||
'sign_in_label' => 'Log in', | |||||
'sign_in_label' => 'Connexion', | |||||
// the 'name' HTML attribute of the <input> used for the username field (default: '_username') | // the 'name' HTML attribute of the <input> used for the username field (default: '_username') | ||||
'username_parameter' => 'email', | 'username_parameter' => 'email', |
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
$query->orderBy('id'); | |||||
return $query; | return $query; | ||||
} | } | ||||
#page-error { | |||||
text-align: center; | |||||
img { | |||||
margin-top: 100px; | |||||
} | |||||
} | |||||
nav.main-header { | nav.main-header { | ||||
ul.navbar-nav { | ul.navbar-nav { | ||||
li.nav-item-user-menu { | li.nav-item-user-menu { |
Lc\SovBundle\EventListener\ExceptionListener: | Lc\SovBundle\EventListener\ExceptionListener: | ||||
tags: | tags: | ||||
- { name: kernel.event_listener, event: kernel.exception } | |||||
- { name: kernel.event_listener, event: kernel.exception } | |||||
parameters: | |||||
app.admin.logo: 'laclic.png' |
<a class="brand-link text-center" | <a class="brand-link text-center" | ||||
title="{{ ea.dashboardTitle|striptags }}" | title="{{ ea.dashboardTitle|striptags }}" | ||||
href="{{ path(ea.dashboardRouteName) }}"> | href="{{ path(ea.dashboardRouteName) }}"> | ||||
{{ ea.dashboardTitle|raw }} | |||||
<!--<span class="brand-text font-weight-light">Texte logo</span>--> | |||||
{{ logo_admin()|raw }} | |||||
</a> | </a> | ||||
{% endblock header_logo %} | {% endblock header_logo %} | ||||
{% extends '@LcSov/adminlte/layout.html.twig' %} | |||||
{% block wrapper %} | |||||
{% block navbar_header %}{% endblock %} | |||||
{% block sidebar %}{% endblock %} | |||||
{% block content %} | |||||
<div id="page-error"> | |||||
<html> | |||||
<div id="page-error"> | |||||
<a href="{{ path('app_admin_dashboard') }}" title="Retourner sur l'admin">Retourner sur l'admin</a> | |||||
<div> | |||||
<a href="{{ path('app_admin_dashboard') }}" title="Retourner sur l'admin"> | |||||
<img src="{{ asset('bundles/lcsov/img/erreur-500.png') }}" alt="ERROR"> | <img src="{{ asset('bundles/lcsov/img/erreur-500.png') }}" alt="ERROR"> | ||||
</div> | |||||
{% endblock %} | |||||
{% endblock %} | |||||
{# {% extends 'layout.html' %} #} | |||||
{# {% set title = 'Erreur' %} #} | |||||
{# {% block page_title %}{% endblock %} #} | |||||
{# {% block title %}{{ title }}{% endblock %} #} | |||||
</a> | |||||
</div> | |||||
</div> | |||||
<style> | |||||
#page-error { | |||||
text-align: center; | |||||
} | |||||
{# {% block content %} #} | |||||
{# {% embed 'bundles/TwigBundle/Exception/_content.html.twig' %} #} | |||||
{# {% block content_error %} #} | |||||
{# <p>Une erreur est survenue.TEST</p> #} | |||||
{# {% endblock %} #} | |||||
{# {% endembed %} #} | |||||
{# {% endblock %} #} | |||||
img { | |||||
margin-top: 100px; | |||||
} | |||||
</style> | |||||
</html> |
protected AdminUrlGenerator $adminUrlGenerator; | protected AdminUrlGenerator $adminUrlGenerator; | ||||
public function __construct( | public function __construct( | ||||
KernelInterface $kernel, | |||||
ParameterBagInterface $parameterBag, | |||||
CacheManager $cacheManager, | |||||
EntityManagerInterface $entityManager, | |||||
RequestStack $requestStack, | |||||
UrlGeneratorInterface $router, | |||||
TranslatorInterface $translator, | |||||
TranslatorAdmin $translatorAdmin, | |||||
ReminderStore $reminderStore, | |||||
Security $security, | |||||
FormFactoryInterface $formFactory, | |||||
StringComponent $stringComponent, | |||||
MetaComponent $metaComponent, | |||||
DateComponent $dateComponent, | |||||
FileComponent $fileComponent, | |||||
AdminUrlGenerator $adminUrlGenerator | |||||
KernelInterface $kernel, | |||||
ParameterBagInterface $parameterBag, | |||||
CacheManager $cacheManager, | |||||
EntityManagerInterface $entityManager, | |||||
RequestStack $requestStack, | |||||
UrlGeneratorInterface $router, | |||||
TranslatorInterface $translator, | |||||
TranslatorAdmin $translatorAdmin, | |||||
ReminderStore $reminderStore, | |||||
Security $security, | |||||
FormFactoryInterface $formFactory, | |||||
StringComponent $stringComponent, | |||||
MetaComponent $metaComponent, | |||||
DateComponent $dateComponent, | |||||
FileComponent $fileComponent, | |||||
AdminUrlGenerator $adminUrlGenerator | |||||
) { | ) { | ||||
$this->kernel = $kernel; | $this->kernel = $kernel; | ||||
$this->parameterBag = $parameterBag; | $this->parameterBag = $parameterBag; | ||||
public function getFunctions() | public function getFunctions() | ||||
{ | { | ||||
return [ | return [ | ||||
new TwigFunction('sov_liip', [$this, 'liip']), | |||||
new TwigFunction('liip', [$this, 'liip']), | |||||
new TwigFunction('sov_get_by_devalias', [$this, 'getByDevAlias']), | |||||
new TwigFunction('sov_parameter', [$this, 'getParameter']), | |||||
new TwigFunction('sov_homepage_route', [$this, 'getHomepageRoute']), | |||||
new TwigFunction('lc_format_price', [$this, 'formatPrice']), | |||||
new TwigFunction('die', [$this, 'die']), | |||||
new TwigFunction('get_form_newsletter', [$this, 'getFormNewsletter']), | |||||
new TwigFunction('sov_limit_text', [$this, 'limitText']), | |||||
new TwigFunction('day_by_number', [$this, 'getDayByNumber']), | |||||
new TwigFunction('user_current', [$this, 'getUserCurrent']), | |||||
new TwigFunction('ea_url_short', [$this, 'generateEaUrl']), | |||||
new TwigFunction('is_instance_of', [$this, 'isInstanceOf']), | |||||
new TwigFunction('sov_liip', [$this, 'liip']), | |||||
new TwigFunction('liip', [$this, 'liip']), | |||||
new TwigFunction('sov_get_by_devalias', [$this, 'getByDevAlias']), | |||||
new TwigFunction('sov_parameter', [$this, 'getParameter']), | |||||
new TwigFunction('sov_homepage_route', [$this, 'getHomepageRoute']), | |||||
new TwigFunction('lc_format_price', [$this, 'formatPrice']), | |||||
new TwigFunction('die', [$this, 'die']), | |||||
new TwigFunction('get_form_newsletter', [$this, 'getFormNewsletter']), | |||||
new TwigFunction('sov_limit_text', [$this, 'limitText']), | |||||
new TwigFunction('day_by_number', [$this, 'getDayByNumber']), | |||||
new TwigFunction('user_current', [$this, 'getUserCurrent']), | |||||
new TwigFunction('ea_url_short', [$this, 'generateEaUrl']), | |||||
new TwigFunction('is_instance_of', [$this, 'isInstanceOf']), | |||||
new TwigFunction('logo_admin', [$this, 'getLogoAdmin']), | |||||
]; | ]; | ||||
} | } | ||||
public function getFilters() | public function getFilters() | ||||
{ | { | ||||
return [ | return [ | ||||
new TwigFilter('uc_first', [$this, 'ucFirst']), | |||||
new TwigFilter('format_price', [$this, 'formatPrice']), | |||||
new TwigFilter('sov_cache', [$this, 'sovCache']), | |||||
new TwigFilter('slugify', [$this, 'slugify']), | |||||
new TwigFilter('md5', [$this, 'md5']), | |||||
new TwigFilter('rot13', [$this, 'rot13']), | |||||
new TwigFilter('uc_first', [$this, 'ucFirst']), | |||||
new TwigFilter('format_price', [$this, 'formatPrice']), | |||||
new TwigFilter('sov_cache', [$this, 'sovCache']), | |||||
new TwigFilter('slugify', [$this, 'slugify']), | |||||
new TwigFilter('md5', [$this, 'md5']), | |||||
new TwigFilter('rot13', [$this, 'rot13']), | |||||
]; | ]; | ||||
} | } | ||||
$reflection = new \ReflectionClass($entity); | $reflection = new \ReflectionClass($entity); | ||||
$interfaceNameArray = $reflection->getInterfaceNames(); | $interfaceNameArray = $reflection->getInterfaceNames(); | ||||
foreach($interfaceNameArray as $interfaceNameEntity) { | |||||
if(strpos($interfaceNameEntity, $interfaceName) !== false) { | |||||
foreach ($interfaceNameArray as $interfaceNameEntity) { | |||||
if (strpos($interfaceNameEntity, $interfaceName) !== false) { | |||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
return $this->security->getUser(); | return $this->security->getUser(); | ||||
} | } | ||||
public function generateEaUrl(string $controller =null, string $action=null, int $entityId=null, array $extraParam = array()): string | |||||
{ | |||||
public function generateEaUrl( | |||||
string $controller = null, | |||||
string $action = null, | |||||
int $entityId = null, | |||||
array $extraParam = array() | |||||
): string { | |||||
$adminUrlGenerator = $this->adminUrlGenerator; | $adminUrlGenerator = $this->adminUrlGenerator; | ||||
if ($controller) { | if ($controller) { | ||||
$adminUrlGenerator->setEntityId($entityId); | $adminUrlGenerator->setEntityId($entityId); | ||||
if($extraParam){ | |||||
foreach ($extraParam as $key=>$value) { | |||||
if ($extraParam) { | |||||
foreach ($extraParam as $key => $value) { | |||||
$adminUrlGenerator->set($key, $value); | $adminUrlGenerator->set($key, $value); | ||||
} | } | ||||
} | } | ||||
{ | { | ||||
return md5($text); | return md5($text); | ||||
} | } | ||||
public function getLogoAdmin(): string | |||||
{ | |||||
return '<img class="logo-admin" src="assets/img/' . $this->getParameter('app.admin.logo') . '" >'; | |||||
} | |||||
} | } |