diff --git a/src/EventSubscriber/MenuBuilderSubscriber.php b/src/EventSubscriber/MenuBuilderSubscriber.php index 2a1c009d..df63808f 100644 --- a/src/EventSubscriber/MenuBuilderSubscriber.php +++ b/src/EventSubscriber/MenuBuilderSubscriber.php @@ -14,10 +14,11 @@ use KevinPapst\AdminLTEBundle\Event\SidebarMenuEvent; use KevinPapst\AdminLTEBundle\Model\MenuItemModel; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; /** * Class MenuBuilder configures the main navigation. + * @internal */ class MenuBuilderSubscriber implements EventSubscriberInterface { @@ -26,19 +27,14 @@ class MenuBuilderSubscriber implements EventSubscriberInterface */ private $eventDispatcher; /** - * @var AuthorizationCheckerInterface + * @var TokenStorageInterface */ - private $security; + private $tokenStorage; - /** - * MenuBuilderSubscriber constructor. - * @param EventDispatcherInterface $dispatcher - * @param AuthorizationCheckerInterface $security - */ - public function __construct(EventDispatcherInterface $dispatcher, AuthorizationCheckerInterface $security) + public function __construct(EventDispatcherInterface $dispatcher, TokenStorageInterface $storage) { $this->eventDispatcher = $dispatcher; - $this->security = $security; + $this->tokenStorage = $storage; } /** @@ -72,7 +68,7 @@ class MenuBuilderSubscriber implements EventSubscriberInterface ); // error pages don't have a user and will fail when is_granted() is called - if (null !== $event->getRequest()->getUser()) { + if (null !== $this->tokenStorage->getToken()) { $this->eventDispatcher->dispatch($menuEvent); } diff --git a/templates/bundles/TwigBundle/Exception/error404.html.twig b/templates/bundles/TwigBundle/Exception/error404.html.twig index 5239fac3..e4ac307f 100644 --- a/templates/bundles/TwigBundle/Exception/error404.html.twig +++ b/templates/bundles/TwigBundle/Exception/error404.html.twig @@ -1 +1,5 @@ {% extends 'error.html.twig' %} + +{% block error_icon %} + +{% endblock %} diff --git a/templates/error.html.twig b/templates/error.html.twig index e99a9377..50d22557 100644 --- a/templates/error.html.twig +++ b/templates/error.html.twig @@ -1,33 +1,51 @@ -{% extends 'base.html.twig' %} +{% extends '@AdminLTE/layout/security-layout.html.twig' %} -{% block page_title %}{{ 'http_error.title'|trans({}, 'exceptions') }}{% endblock %} -{% block page_subtitle %}{{ status_code }}{% endblock %} - -{% block main %} - {% set errorTitleKey = "http_error_#{status_code}.description" %} +{% set errorTitleKey = "http_error_#{status_code}.description" %} +{% set errorTitleTrans = errorTitleKey|trans({ '%status_code%': status_code }, 'exceptions') %} +{% if errorTitleKey == errorTitleTrans %} + {% set errorTitleKey = 'http_error.description' %} {% set errorTitleTrans = errorTitleKey|trans({ '%status_code%': status_code }, 'exceptions') %} - {% if errorTitleKey == errorTitleTrans %} - {% set errorTitleKey = 'http_error.description' %} - {% set errorTitleTrans = errorTitleKey|trans({ '%status_code%': status_code }, 'exceptions') %} - {% endif %} +{% endif %} - {% set errorMessageKey = "http_error_#{status_code}.suggestion" %} +{% set errorMessageKey = "http_error_#{status_code}.suggestion" %} +{% set errorMessageTrans = errorMessageKey|trans({ '%status_code%': status_code }, 'exceptions') %} +{% if errorMessageKey == errorMessageTrans %} + {% set errorMessageKey = 'http_error.suggestion' %} {% set errorMessageTrans = errorMessageKey|trans({ '%status_code%': status_code }, 'exceptions') %} - {% if errorMessageKey == errorMessageTrans %} - {% set errorMessageKey = 'http_error.suggestion' %} - {% set errorMessageTrans = errorMessageKey|trans({ '%status_code%': status_code }, 'exceptions') %} - {% endif %} +{% endif %} -
-

{{ status_code }}

+{% block logo_login %}{% include 'partials/logo_login.html.twig' %}{% endblock %} +{% block title %}{{ status_code }} - {{ 'http_error.title'|trans({}, 'exceptions') }}{% endblock %} - {% block error_content %} -
-

{% block error_icon %}{% endblock %} {{ errorTitleTrans }}

-

{{ errorMessageTrans }}

- {{ 'action.back'|trans }} -
- {% endblock %} - -
+{% block head %} + {{ parent() }} + {% include 'partials/head.html.twig' %} {% endblock %} + +{% block stylesheets %} + {{ encore_entry_link_tags('app') }} +{% endblock %} + +{% block javascripts %} + {{ encore_entry_script_tags('app') }} +{% endblock %} + +{% block login_box_icon %}{% block error_icon %}{% endblock %}{% endblock %} + +{% block login_box_msg %} + {{ errorTitleTrans }} +{% endblock %} + +{% block login_form %} + {% block error_content %} +

+ {{ errorMessageTrans }} +

+

+ {{ 'dashboard.title'|trans }} +

+ {% endblock %} +{% endblock %} + +{% block login_social_auth %}{% endblock %} +{% block login_actions %}{% endblock %} \ No newline at end of file diff --git a/tests/Controller/DashboardControllerTest.php b/tests/Controller/DashboardControllerTest.php index c9399b11..6713a798 100644 --- a/tests/Controller/DashboardControllerTest.php +++ b/tests/Controller/DashboardControllerTest.php @@ -50,25 +50,4 @@ class DashboardControllerTest extends ControllerBaseTest $this->assertTrue($client->getResponse()->isSuccessful()); $this->assertMainContentClass($client, 'dashboard'); } - - /** - * This is not a test for the dashbaord, but for the general layout - */ - public function testUserMenuIsAvailable() - { - $client = $this->getClientForAuthenticatedUser(User::ROLE_USER); - - $em = $client->getContainer()->get('doctrine.orm.entity_manager'); - $user = $this->getUserByRole($em, User::ROLE_USER); - - $this->request($client, '/dashboard/'); - $this->assertTrue($client->getResponse()->isSuccessful()); - - $content = $client->getResponse()->getContent(); - - $this->assertStringContainsString('
  • assertStringContainsString('', $content); + $this->assertStringContainsString('Dashboard', $content); + + $this->assertStringContainsString('
  • assertStringContainsString('', $content); + $this->assertStringContainsString('My times', $content); + + $this->assertStringContainsString('
  • assertStringContainsString('', $content); + $this->assertStringContainsString('Calendar', $content); + } +} diff --git a/translations/exceptions.de.xliff b/translations/exceptions.de.xliff index 1f553828..49a1f648 100644 --- a/translations/exceptions.de.xliff +++ b/translations/exceptions.de.xliff @@ -16,30 +16,29 @@ http_error.description - Oops! Ein Fehler ist aufgetreten. + Etwas läuft falsch http_error.suggestion - Ein unerwarteter Fehler ist aufgetreten. - Möglicherweise haben Sie einen Bug gefunden, daher kontaktieren Sie bitte ihren Administrator - wenn der Fehler nach einem erneuten Versuch immer noch vorhanden sein sollte. + Ein kritischer Fehler ist aufgetreten. + Möglicherweise haben Sie einen Software Fehler gefunden, kontaktieren Sie bitte ihren Administrator wenn der Fehler bestehen bleibt. http_error_404.description - Oops! Seite wurde nicht gefunden. + Seite wurde nicht gefunden http_error_404.suggestion Wir konnten die angeforderte Seite leider nicht finden. - Bitte wechseln Sie zurück zu ihrem Dashboard und starten von vorne. + Bitte wechseln Sie zu ihrem Dashboard und starten von vorne. http_error_403.description - Diese Seite ist geschützt. + Seite ist geschützt http_error_403.suggestion diff --git a/translations/exceptions.en.xliff b/translations/exceptions.en.xliff index a5d5fb06..903f839b 100644 --- a/translations/exceptions.en.xliff +++ b/translations/exceptions.en.xliff @@ -16,35 +16,34 @@ http_error.description - Oops! An error occured. + Something is wrong http_error.suggestion - An unexpected error occured, please try again. - You may have found a bug, so please contact your administrator if the problem - doesn't go away after you tried it again. + A critical error occurred, please try again. + You may have found a software problem, please contact your administrator if the problem persists. http_error_404.description - Oops! Page not found. + Page not found http_error_404.suggestion We could not find the page you were looking for. - Meanwhile, you may return to your dashboard and start over. + Please return to your dashboard and start over. http_error_403.description - This page is restricted. + Page is restricted http_error_403.suggestion - Sorry, but you do not have sufficient permissions to see this page. + Sorry, but you don't have sufficient permissions to see this page. Please talk to your administrator if you think this is an error.