瀏覽代碼

Merge branch 'develop' of https://forge.laclic.fr/Laclic/SovBundle into develop

develop
Fabien Normand 3 年之前
父節點
當前提交
a280ccc99c
共有 9 個文件被更改,包括 81 次插入82 次删除
  1. +3
    -2
      Controller/Dashboard/DashboardAdminController.php
  2. +1
    -1
      Controller/ErrorController.php
  3. +4
    -4
      Controller/Security/SecurityAdminController.php
  4. +0
    -1
      Repository/Site/NewsStore.php
  5. +0
    -8
      Resources/assets/app/adminlte/main/scss/_common.scss
  6. +4
    -1
      Resources/config/services.yaml
  7. +1
    -2
      Resources/views/adminlte/layout.html.twig
  8. +17
    -22
      Resources/views/exception/error.html.twig
  9. +51
    -41
      Twig/TwigExtension.php

+ 3
- 2
Controller/Dashboard/DashboardAdminController.php 查看文件

@@ -19,6 +19,9 @@ class DashboardAdminController extends AbstractDashboardController

use ControllerTrait;

/**
* @Route("/admin", name="app_admin_dashboard")
*/
public function index(): Response
{
return $this->render('@LcSov/adminlte/dashboard.html.twig');
@@ -29,8 +32,6 @@ class DashboardAdminController extends AbstractDashboardController
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/'.$this->get('parameter_bag')->get('app.admin.logo').'" width="100px">')
// the path defined in this method is passed to the Twig asset() function
->setFaviconPath('assets/img/frontend/favicon-pdl.png')
// the domain used by default is 'messages'

+ 1
- 1
Controller/ErrorController.php 查看文件

@@ -10,7 +10,7 @@ class ErrorController extends AbstractController

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', [
"code" => $exception->getCode(),
"message" => $exception->getMessage()

+ 4
- 4
Controller/Security/SecurityAdminController.php 查看文件

@@ -40,7 +40,7 @@ class SecurityAdminController extends AbstractController
// 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
// 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
// this parameter, the login form won't include a CSRF token
@@ -50,13 +50,13 @@ class SecurityAdminController extends AbstractController
'target_path' => $this->generateUrl('app_admin_dashboard'),

// 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)
'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)
'sign_in_label' => 'Log in',
'sign_in_label' => 'Connexion',

// the 'name' HTML attribute of the <input> used for the username field (default: '_username')
'username_parameter' => 'email',

+ 0
- 1
Repository/Site/NewsStore.php 查看文件

@@ -18,7 +18,6 @@ class NewsStore extends AbstractStore implements NewsStoreInterface

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}


+ 0
- 8
Resources/assets/app/adminlte/main/scss/_common.scss 查看文件

@@ -1,11 +1,3 @@
#page-error {
text-align: center;

img {
margin-top: 100px;
}
}

nav.main-header {
ul.navbar-nav {
li.nav-item-user-menu {

+ 4
- 1
Resources/config/services.yaml 查看文件

@@ -38,4 +38,7 @@ services:

Lc\SovBundle\EventListener\ExceptionListener:
tags:
- { name: kernel.event_listener, event: kernel.exception }
- { name: kernel.event_listener, event: kernel.exception }

parameters:
app.admin.logo: 'laclic.png'

+ 1
- 2
Resources/views/adminlte/layout.html.twig 查看文件

@@ -89,8 +89,7 @@
<a class="brand-link text-center"
title="{{ ea.dashboardTitle|striptags }}"
href="{{ path(ea.dashboardRouteName) }}">
{{ ea.dashboardTitle|raw }}
<!--<span class="brand-text font-weight-light">Texte logo</span>-->
{{ logo_admin()|raw }}
</a>
{% endblock header_logo %}


+ 17
- 22
Resources/views/exception/error.html.twig 查看文件

@@ -1,24 +1,19 @@
{% 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">
</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>

+ 51
- 41
Twig/TwigExtension.php 查看文件

@@ -47,22 +47,22 @@ class TwigExtension extends AbstractExtension
protected AdminUrlGenerator $adminUrlGenerator;

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->parameterBag = $parameterBag;
@@ -85,19 +85,20 @@ class TwigExtension extends AbstractExtension
public function getFunctions()
{
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']),
];
}

@@ -109,12 +110,12 @@ class TwigExtension extends AbstractExtension
public function getFilters()
{
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']),
];
}

@@ -128,8 +129,8 @@ class TwigExtension extends AbstractExtension
$reflection = new \ReflectionClass($entity);
$interfaceNameArray = $reflection->getInterfaceNames();

foreach($interfaceNameArray as $interfaceNameEntity) {
if(strpos($interfaceNameEntity, $interfaceName) !== false) {
foreach ($interfaceNameArray as $interfaceNameEntity) {
if (strpos($interfaceNameEntity, $interfaceName) !== false) {
return true;
}
}
@@ -207,8 +208,12 @@ class TwigExtension extends AbstractExtension
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;

if ($controller) {
@@ -220,8 +225,8 @@ class TwigExtension extends AbstractExtension

$adminUrlGenerator->setEntityId($entityId);

if($extraParam){
foreach ($extraParam as $key=>$value) {
if ($extraParam) {
foreach ($extraParam as $key => $value) {
$adminUrlGenerator->set($key, $value);
}
}
@@ -232,4 +237,9 @@ class TwigExtension extends AbstractExtension
{
return md5($text);
}

public function getLogoAdmin(): string
{
return '<img class="logo-admin" src="assets/img/' . $this->getParameter('app.admin.logo') . '" >';
}
}

Loading…
取消
儲存