From ca8fcfeae8b15579f76dafce30fa9157de7a2ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Bouch=C3=A9?= Date: Wed, 8 Nov 2023 10:59:18 +0100 Subject: [PATCH 1/2] Ibexa 4 support --- .travis.yml | 4 +- README.md | 4 +- composer.json | 11 ++- src/Controller/LogsManagerController.php | 6 +- src/IbexaLogsUiBundle.php | 2 +- .../views/themes/admin/logs/logs.html.twig | 68 ++++++++++--------- src/Security/LogsUiProvider.php | 2 +- 7 files changed, 52 insertions(+), 45 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3a77b61..8af2664 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,8 @@ env: matrix: fast_finish: true include: - - php: 7.3 - - php: 7.3 + - php: 7.4 + - php: 7.4 env: SETUP=lowest - php: 8.0 - php: 8.0 diff --git a/README.md b/README.md index ea8ff45..5a7cd75 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,8 @@ Symfony bundle dedicated to Ibexa, to add a log management interface to the back ## Requirements -* php: >=7.3 -* ibexa: 3.3.* +* php: >=7.4 +* ibexa: 4.0+ :warning: Warning, in its current version, the bundle **only supports** log files in `Monolog/LineFormatter` format. [LineFormatter from Github](https://github.com/Seldaek/monolog/blob/master/src/Monolog/Formatter/LineFormatter.php) diff --git a/composer.json b/composer.json index 59cecd0..22877bb 100644 --- a/composer.json +++ b/composer.json @@ -22,9 +22,11 @@ } }, "require": { - "php": ">=7.3", + "php": ">=7.4", "ext-json": "*", - "ezsystems/ezplatform-admin-ui": "^2.3", + "http-interop/http-factory-guzzle": "^1.2", + "ibexa/admin-ui": "^4.0", + "ibexa/core": "^4.0", "monolog/monolog": "^2.2", "symfony/cache": "^5.2", "symfony/web-profiler-bundle": "^5.2" @@ -38,6 +40,9 @@ "prefer-stable": true, "config": { "optimize-autoloader": true, - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "php-http/discovery": true + } } } diff --git a/src/Controller/LogsManagerController.php b/src/Controller/LogsManagerController.php index 64eb5bc..b675c18 100644 --- a/src/Controller/LogsManagerController.php +++ b/src/Controller/LogsManagerController.php @@ -2,10 +2,10 @@ namespace IbexaLogsUi\Bundle\Controller; -use eZ\Publish\Core\MVC\Symfony\Security\Authorization\Attribute; +use Ibexa\Core\MVC\Symfony\Security\Authorization\Attribute; use IbexaLogsUi\Bundle\LogManager\LogFile; use IbexaLogsUi\Bundle\LogManager\LogsCache; -use EzSystems\EzPlatformAdminUiBundle\Controller\Controller; +use Ibexa\Contracts\AdminUi\Controller\Controller; use Monolog\Handler\HandlerInterface; use Monolog\Logger; use Symfony\Component\HttpFoundation\Response; @@ -116,7 +116,7 @@ private function renderLogs( array $logs = [], array $logLevels = LogFile::LOG_LEVELS ): Response { - return $this->render('@ezdesign/logs/logs.html.twig', [ + return $this->render('@ibexadesign/logs/logs.html.twig', [ 'log_path' => $logPath, 'level' => $level, 'page' => $page, diff --git a/src/IbexaLogsUiBundle.php b/src/IbexaLogsUiBundle.php index 882f9e0..f0fc541 100644 --- a/src/IbexaLogsUiBundle.php +++ b/src/IbexaLogsUiBundle.php @@ -20,7 +20,7 @@ public function build(ContainerBuilder $container): void { parent::build($container); - $eZExtension = $container->getExtension('ezpublish'); + $eZExtension = $container->getExtension('ibexa'); $eZExtension->addPolicyProvider(new LogsUiProvider); } } diff --git a/src/Resources/views/themes/admin/logs/logs.html.twig b/src/Resources/views/themes/admin/logs/logs.html.twig index c02c4c9..df23606 100644 --- a/src/Resources/views/themes/admin/logs/logs.html.twig +++ b/src/Resources/views/themes/admin/logs/logs.html.twig @@ -1,14 +1,14 @@ -{% extends ['@ezdesign/layout.html.twig', '@ezdesign/ui/layout.html.twig'] %} +{% extends ['@ibexadesign/layout.html.twig', '@ibexadesign/ui/layout.html.twig'] %} {% block breadcrumbs %} - {% include ['@ezdesign/parts/breadcrumbs.html.twig', '@ezdesign/ui/breadcrumbs.html.twig'] with { items: [ + {% include ['@ibexadesign/parts/breadcrumbs.html.twig', '@ibexadesign/ui/breadcrumbs.html.twig'] with { items: [ { value: 'breadcrumb.admin'|trans(domain='messages')|desc('Admin') }, { value: 'logs_ui.menu.label'|trans } ]} %} {% endblock %} {% block page_title %} - {% include ['@ezdesign/parts/page_title.html.twig', '@ezdesign/ui/page_title.html.twig'] with { + {% include ['@ibexadesign/parts/page_title.html.twig', '@ibexadesign/ui/page_title.html.twig'] with { title: 'logs_ui.menu.label'|trans, iconName: 'contentlist' } %} @@ -19,43 +19,45 @@ {% set max_logs = constant('IbexaLogsUi\\Bundle\\Controller\\LogsManagerController::MAX_LOGS') %} {% set pages = (total / per_page_logs)|round(0, 'ceil') %} -
-
-
+
+
+
-
+
{{ 'logs_ui.text.last_message'|trans }} {{ logs is not empty ? logs|first.date|date('d/m/Y H:i') : '#' }}
{{ log_path }}
- - +
-
+
{% if per_page_logs < total %}
{% if page != 1 %} @@ -74,24 +76,24 @@ {{ 'logs_ui.text.log_path'|trans }} {{ log_path }}

{% else %} - +
- - - - + + + + {% for log in logs %} - - - + + -
DateLoggerMessage
DateLoggerMessage
{{ log.date|date('d/m/Y H:i:s') }} +
{{ log.date|date('d/m/Y H:i:s') }}
{{ log.logger }}.{{ log.level }}
+ {{ dump_log_message(log.message, log.context) }} {% if log.context is not empty or log.extra is not empty %}
@@ -117,7 +119,7 @@
{% endif %} - {% from '@ezdesign/logs/pagination.html.twig' import pagination %} + {% from '@ibexadesign/logs/pagination.html.twig' import pagination %} {{ pagination(pages, page, path('ibexa_logs_ui_index') ~ '/' ~ level ~ '/', logs|length, total) }}
{% endblock %} diff --git a/src/Security/LogsUiProvider.php b/src/Security/LogsUiProvider.php index d666b40..2c5fdc9 100644 --- a/src/Security/LogsUiProvider.php +++ b/src/Security/LogsUiProvider.php @@ -2,7 +2,7 @@ namespace IbexaLogsUi\Bundle\Security; -use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Security\PolicyProvider\YamlPolicyProvider; +use Ibexa\Bundle\Core\DependencyInjection\Security\PolicyProvider\YamlPolicyProvider; class LogsUiProvider extends YamlPolicyProvider { From c01db4a581295ffc0a5190599594d141a59afcac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Bouch=C3=A9?= Date: Wed, 8 Nov 2023 11:26:16 +0100 Subject: [PATCH 2/2] Ibexa 4 support (2) --- src/EventSubscriber/MenuSubscriber.php | 1 + .../views/themes/admin/logs/logs.html.twig | 64 ++++++++----------- .../themes/admin/logs/pagination.html.twig | 16 ++--- 3 files changed, 37 insertions(+), 44 deletions(-) diff --git a/src/EventSubscriber/MenuSubscriber.php b/src/EventSubscriber/MenuSubscriber.php index 9dfa87e..fa3d5db 100644 --- a/src/EventSubscriber/MenuSubscriber.php +++ b/src/EventSubscriber/MenuSubscriber.php @@ -26,6 +26,7 @@ public function onConfigureMenu(ConfigureMenuEvent $event): void $menu[MainMenuBuilder::ITEM_ADMIN]->addChild('logs_ui', [ 'label' => 'logs_ui.menu.label', 'route' => 'ibexa_logs_ui_index', + 'extras' => ['translation_domain' => 'messages'] ]); } } diff --git a/src/Resources/views/themes/admin/logs/logs.html.twig b/src/Resources/views/themes/admin/logs/logs.html.twig index df23606..7298caf 100644 --- a/src/Resources/views/themes/admin/logs/logs.html.twig +++ b/src/Resources/views/themes/admin/logs/logs.html.twig @@ -7,7 +7,7 @@ ]} %} {% endblock %} -{% block page_title %} +{% block header %} {% include ['@ibexadesign/parts/page_title.html.twig', '@ibexadesign/ui/page_title.html.twig'] with { title: 'logs_ui.menu.label'|trans, iconName: 'contentlist' @@ -19,45 +19,37 @@ {% set max_logs = constant('IbexaLogsUi\\Bundle\\Controller\\LogsManagerController::MAX_LOGS') %} {% set pages = (total / per_page_logs)|round(0, 'ceil') %} -
-
-
-
-
- {{ 'logs_ui.text.last_message'|trans }} {{ logs is not empty ? logs|first.date|date('d/m/Y H:i') : '#' }} -
- {{ log_path }} -
-
- - - - - {{ 'logs_ui.text.reload'|trans }} - +
+
+
+
+ {{ 'logs_ui.text.last_message'|trans }} {{ logs is not empty ? logs|first.date|date('d/m/Y H:i') : '#' }}
+ {{ log_path }}
- - + +
+ + {{ 'logs_ui.text.all_levels'|trans }} + + {% for item in log_levels %} + + {{ item }} + + {% endfor %} +
-
+
{% if per_page_logs < total %}
{% if page != 1 %} @@ -76,7 +68,7 @@ {{ 'logs_ui.text.log_path'|trans }} {{ log_path }}

{% else %} - +
@@ -89,7 +81,7 @@ diff --git a/src/Resources/views/themes/admin/logs/pagination.html.twig b/src/Resources/views/themes/admin/logs/pagination.html.twig index 5b2d760..3689bce 100644 --- a/src/Resources/views/themes/admin/logs/pagination.html.twig +++ b/src/Resources/views/themes/admin/logs/pagination.html.twig @@ -1,28 +1,28 @@ {% macro pagination(pages, current, url, perPageLogs, total, nearbyPagesLimit = 4) %} {% if pages > 1 %} -
-
+
+
{{ 'logs_ui.text.pagination'|trans({'%perPage%': perPageLogs|number_format(0, ',', ' '), '%total%': total|number_format(0, ',', ' ')})|raw }}
-
    +
      {% for i in 1..pages %} {% if 0 == (current - nearbyPagesLimit) - loop.index %} -
    • +
    • 1
    • {% if 1 != loop.index %} -
    • +
    • {% endif %} {% elseif 0 == (current + nearbyPagesLimit) - loop.index and (current + nearbyPagesLimit) < pages %} -
    • +
    • {% elseif 0 < (current - nearbyPagesLimit) - loop.index %} {% elseif 0 > (current + nearbyPagesLimit) - loop.index %} {% else %} -
    • +
    • {% if current == loop.index %} {% else %} @@ -32,7 +32,7 @@ {% endif %} {% endfor %} {% if current != pages and (current + nearbyPagesLimit) < pages %} -
    • +
    • {{ pages }}
    • {% endif %}
Date
{{ log.date|date('d/m/Y H:i:s') }} -
+
{{ log.logger }}.{{ log.level }}