From b0398304f57c99fb8de09278a6a54dfd502d7fd1 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 11 Apr 2021 17:15:51 +0200 Subject: [PATCH] backports murph-skeleton --- core/Cache/SymfonyCacheManager.php | 11 ++++- .../Account/AccountAdminController.php | 2 +- core/Controller/Site/PageController.php | 6 +-- .../EntityManagerEventSubscriber.php | 14 +++--- .../Site/MenuEventSubscriber.php | 2 +- .../Site/SiteEventSubscriber.php | 6 +-- core/Repository/RepositoryQuery.php | 43 ++++++++++--------- core/Resources/translations/messages.fr.yaml | 5 +++ core/Resources/views/auth/2fa.html.twig | 9 +--- core/Resources/views/auth/login.html.twig | 2 +- .../views/auth/resetting_request.html.twig | 2 +- .../views/auth/resetting_update.html.twig | 2 +- .../site/navigation_admin/edit.html.twig | 2 + .../site/navigation_admin/index.html.twig | 4 +- .../views/site/navigation_admin/new.html.twig | 2 + .../site/navigation_admin/show.html.twig | 2 + .../views/site/page_admin/edit.html.twig | 2 + .../views/site/page_admin/index.html.twig | 4 +- .../site/tree_admin/navigation.html.twig | 2 + .../views/user/user_admin/edit.html.twig | 2 + .../views/user/user_admin/index.html.twig | 4 +- .../views/user/user_admin/new.html.twig | 2 + .../views/user/user_admin/show.html.twig | 2 + core/Sitemap/SitemapBuilder.php | 4 ++ 24 files changed, 85 insertions(+), 51 deletions(-) diff --git a/core/Cache/SymfonyCacheManager.php b/core/Cache/SymfonyCacheManager.php index da72bad..4fb7fe2 100644 --- a/core/Cache/SymfonyCacheManager.php +++ b/core/Cache/SymfonyCacheManager.php @@ -40,12 +40,21 @@ class SymfonyCacheManager { $application = new Application($this->kernel); $application->setAutoExit(false); + $output = new BufferedOutput(); $input = new ArrayInput([ 'command' => 'cache:clear', + '-e' => $this->kernel->getEnvironment(), + '--no-warmup' => null, + ]); + + $application->run($input, $output); + + $input = new ArrayInput([ + 'command' => 'cache:warmup', + '-e' => $this->kernel->getEnvironment(), ]); - $output = new BufferedOutput(); $application->run($input, $output); } } diff --git a/core/Controller/Account/AccountAdminController.php b/core/Controller/Account/AccountAdminController.php index 4a3ad04..5ea4b6e 100644 --- a/core/Controller/Account/AccountAdminController.php +++ b/core/Controller/Account/AccountAdminController.php @@ -4,7 +4,7 @@ namespace App\Core\Controller\Account; use App\Core\Controller\Admin\AdminController; use App\Core\Manager\EntityManager; -use App\Core\Repository\UserRepository; +use App\Repository\UserRepository; use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Google\GoogleAuthenticatorInterface; use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Google\GoogleAuthenticatorInterface as TotpAuthenticatorInterface; use Symfony\Component\HttpFoundation\Request; diff --git a/core/Controller/Site/PageController.php b/core/Controller/Site/PageController.php index bf08f41..644fd83 100644 --- a/core/Controller/Site/PageController.php +++ b/core/Controller/Site/PageController.php @@ -19,13 +19,13 @@ class PageController extends AbstractController $this->siteStore = $siteStore; } - public function show(Request $request, SiteRequest $siteRequest): Response + public function show(): Response { - if (!$siteRequest->getPage()) { + if (!$this->siteRequest->getPage()) { throw $this->createNotFoundException(); } - return $this->defaultRender($siteRequest->getPage()->getTemplate()); + return $this->defaultRender($this->siteRequest->getPage()->getTemplate()); } protected function defaultRender(string $view, array $parameters = [], Response $response = null): Response diff --git a/core/EventSuscriber/EntityManagerEventSubscriber.php b/core/EventSuscriber/EntityManagerEventSubscriber.php index 586fbf4..8d663dc 100644 --- a/core/EventSuscriber/EntityManagerEventSubscriber.php +++ b/core/EventSuscriber/EntityManagerEventSubscriber.php @@ -12,15 +12,17 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; */ abstract class EntityManagerEventSubscriber implements EventSubscriberInterface { + static protected int $priority = 0; + public static function getSubscribedEvents() { return [ - EntityManagerEvent::CREATE_EVENT => 'onCreate', - EntityManagerEvent::UPDATE_EVENT => 'onUpdate', - EntityManagerEvent::DELETE_EVENT => 'onDelete', - EntityManagerEvent::PRE_CREATE_EVENT => 'onPreCreate', - EntityManagerEvent::PRE_UPDATE_EVENT => 'onPreUpdate', - EntityManagerEvent::PRE_DELETE_EVENT => 'onPreDelete', + EntityManagerEvent::CREATE_EVENT => ['onCreate', self::$priority], + EntityManagerEvent::UPDATE_EVENT => ['onUpdate', self::$priority], + EntityManagerEvent::DELETE_EVENT => ['onDelete', self::$priority], + EntityManagerEvent::PRE_CREATE_EVENT => ['onPreCreate', self::$priority], + EntityManagerEvent::PRE_UPDATE_EVENT => ['onPreUpdate', self::$priority], + EntityManagerEvent::PRE_DELETE_EVENT => ['onPreDelete', self::$priority], ]; } diff --git a/core/EventSuscriber/Site/MenuEventSubscriber.php b/core/EventSuscriber/Site/MenuEventSubscriber.php index 72335c3..56ab531 100644 --- a/core/EventSuscriber/Site/MenuEventSubscriber.php +++ b/core/EventSuscriber/Site/MenuEventSubscriber.php @@ -88,7 +88,7 @@ class MenuEventSubscriber extends EntityManagerEventSubscriber $this->nodeRepository->persistAsFirstChild($childNode, $rootNode); - $this->cacheManager->cleanAll(); + $this->cacheManager->cleanRouting(); } public function onUpdate(EntityManagerEvent $event) diff --git a/core/EventSuscriber/Site/SiteEventSubscriber.php b/core/EventSuscriber/Site/SiteEventSubscriber.php index 6c6a8c3..db9d5e6 100644 --- a/core/EventSuscriber/Site/SiteEventSubscriber.php +++ b/core/EventSuscriber/Site/SiteEventSubscriber.php @@ -39,11 +39,7 @@ class SiteEventSubscriber extends EntityManagerEventSubscriber return; } - if ($event->getEntity() instanceof Node) { - $this->cacheManager->cleanRouting(); - } else { - $this->cacheManager->cleanAll(); - } + $this->cacheManager->cleanRouting(); } public function onCreate(EntityManagerEvent $event) diff --git a/core/Repository/RepositoryQuery.php b/core/Repository/RepositoryQuery.php index 27addf9..05a4a86 100644 --- a/core/Repository/RepositoryQuery.php +++ b/core/Repository/RepositoryQuery.php @@ -28,28 +28,8 @@ abstract class RepositoryQuery public function __call(string $name, $params): self { - $fn = function (&$data) { - if (is_string($data)) { - $words = explode(' ', $data); - - foreach ($words as $k => $v) { - if (isset($v[0]) && '.' === $v[0]) { - $words[$k] = $this->id.$v; - } - } - - $data = implode(' ', $words); - } elseif (is_array($data)) { - foreach ($data as $k => $v) { - $fn($data[$k]); - } - } - - return $data; - }; - foreach ($params as $key => $value) { - $fn($params[$key]); + $this->populateDqlId($params[$key]); } call_user_func_array([$this->query, $name], $params); @@ -93,4 +73,25 @@ abstract class RepositoryQuery { return $this->repository; } + + protected function populateDqlId(&$data) + { + if (is_string($data)) { + $words = explode(' ', $data); + + foreach ($words as $k => $v) { + if (isset($v[0]) && '.' === $v[0]) { + $words[$k] = $this->id.$v; + } + } + + $data = implode(' ', $words); + } elseif (is_array($data)) { + foreach ($data as $k => $v) { + $this->populateDqlId($data[$k]); + } + } + + return $data; + } } diff --git a/core/Resources/translations/messages.fr.yaml b/core/Resources/translations/messages.fr.yaml index bc61624..61b0f18 100644 --- a/core/Resources/translations/messages.fr.yaml +++ b/core/Resources/translations/messages.fr.yaml @@ -121,3 +121,8 @@ "Show the login page": "Afficher la page de connexion" "A password reset request has been made. If you are the source of this request, click on the link below or copy and paste the address if the link does not work.": "Une demande de réinitialisation de mot de passe a été réalisée. Si vous êtes à l'origine de cette demande, cliquer sur le lien ci-dessous ou copier et coller l'adresse si le lien ne fonctionne pas." "Edit the routing": "Éditez le routage" +"Name": "Nom" +"Authentication": "Authentification" +"Anyway": "Peu importe" +"Yes": "Oui" +"No": "Non" diff --git a/core/Resources/views/auth/2fa.html.twig b/core/Resources/views/auth/2fa.html.twig index 60fea25..d6d2768 100644 --- a/core/Resources/views/auth/2fa.html.twig +++ b/core/Resources/views/auth/2fa.html.twig @@ -4,7 +4,7 @@ {{ include('@Core/admin/module/metas.html.twig') }} - {% block title %}{{ site_name }} {% endblock %} + {% block title %}{{ 'Authentication'|trans }}{% endblock %} {% block css %} {{ encore_entry_link_tags('admin') }} @@ -13,7 +13,7 @@
-
+
-
-
- -
-
diff --git a/core/Resources/views/auth/login.html.twig b/core/Resources/views/auth/login.html.twig index bde612e..e4895a1 100644 --- a/core/Resources/views/auth/login.html.twig +++ b/core/Resources/views/auth/login.html.twig @@ -4,7 +4,7 @@ {{ include('@Core/admin/module/metas.html.twig') }} - {% block title %}{{ site_name }}{% endblock %} + {% block title %}{{ 'Authentication'|trans }} - {{ site_name }}{% endblock %} {% block css %} {{ encore_entry_link_tags('admin') }} diff --git a/core/Resources/views/auth/resetting_request.html.twig b/core/Resources/views/auth/resetting_request.html.twig index eb72385..6dbcf39 100644 --- a/core/Resources/views/auth/resetting_request.html.twig +++ b/core/Resources/views/auth/resetting_request.html.twig @@ -4,7 +4,7 @@ {{ include('@Core/admin/module/metas.html.twig') }} - {% block title %}{{ site_name }}{% endblock %} + {% block title %}{{ 'Authentication'|trans }} - {{ site_name }}{% endblock %} {% block css %} {{ encore_entry_link_tags('admin') }} diff --git a/core/Resources/views/auth/resetting_update.html.twig b/core/Resources/views/auth/resetting_update.html.twig index 7616a4c..9ecf5fd 100644 --- a/core/Resources/views/auth/resetting_update.html.twig +++ b/core/Resources/views/auth/resetting_update.html.twig @@ -4,7 +4,7 @@ {{ include('@Core/admin/module/metas.html.twig') }} - {% block title %}{{ site_name }}{% endblock %} + {% block title %}{{ 'Authentication'|trans }} - {{ site_name }}{% endblock %} {% block css %} {{ encore_entry_link_tags('admin') }} diff --git a/core/Resources/views/site/navigation_admin/edit.html.twig b/core/Resources/views/site/navigation_admin/edit.html.twig index aab954c..1c1e577 100644 --- a/core/Resources/views/site/navigation_admin/edit.html.twig +++ b/core/Resources/views/site/navigation_admin/edit.html.twig @@ -1,5 +1,7 @@ {% extends '@Core/admin/layout.html.twig' %} +{% block title %}{{ 'Navigations'|trans }} - {{ parent() }}{% endblock %} + {% block body %}
diff --git a/core/Resources/views/site/navigation_admin/index.html.twig b/core/Resources/views/site/navigation_admin/index.html.twig index f388a67..78f3fd9 100644 --- a/core/Resources/views/site/navigation_admin/index.html.twig +++ b/core/Resources/views/site/navigation_admin/index.html.twig @@ -1,7 +1,9 @@ {% extends '@Core/admin/layout.html.twig' %} +{% block title %}{{ 'Navigations'|trans }} - {{ parent() }}{% endblock %} + {% block body %} -
+

diff --git a/core/Resources/views/site/navigation_admin/new.html.twig b/core/Resources/views/site/navigation_admin/new.html.twig index 5284fe3..d9cb503 100644 --- a/core/Resources/views/site/navigation_admin/new.html.twig +++ b/core/Resources/views/site/navigation_admin/new.html.twig @@ -1,5 +1,7 @@ {% extends '@Core/admin/layout.html.twig' %} +{% block title %}{{ 'Navigations'|trans }} - {{ parent() }}{% endblock %} + {% block body %}
diff --git a/core/Resources/views/site/navigation_admin/show.html.twig b/core/Resources/views/site/navigation_admin/show.html.twig index 50b1631..a1d2aac 100644 --- a/core/Resources/views/site/navigation_admin/show.html.twig +++ b/core/Resources/views/site/navigation_admin/show.html.twig @@ -1,5 +1,7 @@ {% extends '@Core/admin/layout.html.twig' %} +{% block title %}{{ 'Navigations'|trans }} - {{ parent() }}{% endblock %} + {% block body %}
diff --git a/core/Resources/views/site/page_admin/edit.html.twig b/core/Resources/views/site/page_admin/edit.html.twig index fef3c66..b833ff7 100644 --- a/core/Resources/views/site/page_admin/edit.html.twig +++ b/core/Resources/views/site/page_admin/edit.html.twig @@ -1,5 +1,7 @@ {% extends '@Core/admin/layout.html.twig' %} +{% block title %}{{ 'Pages'|trans }} - {{ parent() }}{% endblock %} + {% block body %}
diff --git a/core/Resources/views/site/page_admin/index.html.twig b/core/Resources/views/site/page_admin/index.html.twig index 7101be6..e60a961 100644 --- a/core/Resources/views/site/page_admin/index.html.twig +++ b/core/Resources/views/site/page_admin/index.html.twig @@ -1,7 +1,9 @@ {% extends '@Core/admin/layout.html.twig' %} +{% block title %}{{ 'Pages'|trans }} - {{ parent() }}{% endblock %} + {% block body %} -
+

{{ 'Pages'|trans }}

diff --git a/core/Resources/views/site/tree_admin/navigation.html.twig b/core/Resources/views/site/tree_admin/navigation.html.twig index 9a17559..aadeb8a 100644 --- a/core/Resources/views/site/tree_admin/navigation.html.twig +++ b/core/Resources/views/site/tree_admin/navigation.html.twig @@ -1,5 +1,7 @@ {% extends '@Core/admin/layout.html.twig' %} +{% block title %}{{ 'Tree'|trans }} - {{ parent() }}{% endblock %} + {% block body %}
diff --git a/core/Resources/views/user/user_admin/edit.html.twig b/core/Resources/views/user/user_admin/edit.html.twig index 51e13d7..6cf5923 100644 --- a/core/Resources/views/user/user_admin/edit.html.twig +++ b/core/Resources/views/user/user_admin/edit.html.twig @@ -1,5 +1,7 @@ {% extends '@Core/admin/layout.html.twig' %} +{% block title %}{{ 'Users'|trans }} - {{ parent() }}{% endblock %} + {% block body %}
diff --git a/core/Resources/views/user/user_admin/index.html.twig b/core/Resources/views/user/user_admin/index.html.twig index 9b130e8..3e02929 100644 --- a/core/Resources/views/user/user_admin/index.html.twig +++ b/core/Resources/views/user/user_admin/index.html.twig @@ -1,7 +1,9 @@ {% extends '@Core/admin/layout.html.twig' %} +{% block title %}{{ 'Users'|trans }} - {{ parent() }}{% endblock %} + {% block body %} -
+

{{ 'Users'|trans }}

diff --git a/core/Resources/views/user/user_admin/new.html.twig b/core/Resources/views/user/user_admin/new.html.twig index ac73f03..8269bba 100644 --- a/core/Resources/views/user/user_admin/new.html.twig +++ b/core/Resources/views/user/user_admin/new.html.twig @@ -1,5 +1,7 @@ {% extends '@Core/admin/layout.html.twig' %} +{% block title %}{{ 'Users'|trans }} - {{ parent() }}{% endblock %} + {% block body %}
diff --git a/core/Resources/views/user/user_admin/show.html.twig b/core/Resources/views/user/user_admin/show.html.twig index 227d740..fef6708 100644 --- a/core/Resources/views/user/user_admin/show.html.twig +++ b/core/Resources/views/user/user_admin/show.html.twig @@ -1,5 +1,7 @@ {% extends '@Core/admin/layout.html.twig' %} +{% block title %}{{ 'Users'|trans }} - {{ parent() }}{% endblock %} + {% block body %}
diff --git a/core/Sitemap/SitemapBuilder.php b/core/Sitemap/SitemapBuilder.php index 30a59c5..ba6f02a 100644 --- a/core/Sitemap/SitemapBuilder.php +++ b/core/Sitemap/SitemapBuilder.php @@ -38,6 +38,10 @@ class SitemapBuilder foreach ($rootNode->getAllChildren() as $node) { $parameters = $node->getSitemapParameters(); + if (!$parameters['isVisible']) { + continue; + } + if ($node->hasExternalUrl()) { continue; }