From eed6fcdd8ba992bfad8e4fa6ed16448c672940fe Mon Sep 17 00:00:00 2001 From: wladyslaw Date: Fri, 10 Jun 2022 12:11:38 +0200 Subject: [PATCH] implemented twin-elements/crud-logger --- composer.json | 3 +- src/Controller/AdminUserController.php | 1 - src/Helper/CrudLoggerMessage.php | 34 --------------------- src/Model/CrudControllerTrait.php | 9 ++---- src/config/config.yaml | 9 ++++++ src/config/services.xml | 42 ++++++++++++++++++-------- 6 files changed, 43 insertions(+), 55 deletions(-) delete mode 100644 src/Helper/CrudLoggerMessage.php diff --git a/composer.json b/composer.json index f6febf1..5eb2c45 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,8 @@ "twin-elements/message": "^1.3", "symfonycasts/reset-password-bundle": "^1.13", "twin-elements/response-parameter-builder": "^1.0", - "twin-elements/admin-translator": "^1.0" + "twin-elements/admin-translator": "^1.0", + "twin-elements/crud-logger": "^1.0" }, "autoload": { "psr-4": { diff --git a/src/Controller/AdminUserController.php b/src/Controller/AdminUserController.php index cb01c4a..9f468f6 100644 --- a/src/Controller/AdminUserController.php +++ b/src/Controller/AdminUserController.php @@ -10,7 +10,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; use TwinElements\AdminBundle\Model\CrudControllerTrait; use TwinElements\AdminBundle\Repository\AdminUserRepository; use TwinElements\AdminBundle\Role\AdminUserRole; diff --git a/src/Helper/CrudLoggerMessage.php b/src/Helper/CrudLoggerMessage.php deleted file mode 100644 index feb6424..0000000 --- a/src/Helper/CrudLoggerMessage.php +++ /dev/null @@ -1,34 +0,0 @@ -routeName = $request->getCurrentRequest()->get('_route'); - $this->username = $tokenStorage->getToken()->getUsername(); - $this->logger = $logger; - } - - public function createLog(int $id, string $title): void - { - $this->logger->info('User: ' . $this->username . '; Route: ' . $this->routeName . '; title: ' . $title . '; ID ' . $id); - } -} diff --git a/src/Model/CrudControllerTrait.php b/src/Model/CrudControllerTrait.php index d3ded74..2be72f8 100644 --- a/src/Model/CrudControllerTrait.php +++ b/src/Model/CrudControllerTrait.php @@ -3,8 +3,8 @@ namespace TwinElements\AdminBundle\Model; use TwinElements\AdminBundle\Helper\Breadcrumbs; -use TwinElements\AdminBundle\Helper\CrudLoggerMessage; use TwinElements\Component\AdminTranslator\AdminTranslator; +use TwinElements\Component\CrudLogger\CrudLoggerInterface; use TwinElements\Component\Flashes\Flashes; trait CrudControllerTrait @@ -13,17 +13,14 @@ trait CrudControllerTrait protected Flashes $flashes; - protected CrudLoggerMessage $crudLogger; + protected CrudLoggerInterface $crudLogger; protected AdminTranslator $adminTranslator; - /** - * @param $breadcrumbs - */ public function __construct( Breadcrumbs $breadcrumbs, Flashes $flashes, - CrudLoggerMessage $crudLogger, + CrudLoggerInterface $crudLogger, AdminTranslator $translator ) { diff --git a/src/config/config.yaml b/src/config/config.yaml index 9027c7a..bffedf7 100644 --- a/src/config/config.yaml +++ b/src/config/config.yaml @@ -1,5 +1,14 @@ symfonycasts_reset_password: request_password_repository: TwinElements\AdminBundle\Repository\ResetPasswordRequestRepository +monolog: + channels: ['crud'] + handlers: + crud: + type: stream + level: info + path: '%kernel.logs_dir%/crud.log' + channels: ['crud'] + twin_elements_admin: admin_locale: '%admin_locale%' diff --git a/src/config/services.xml b/src/config/services.xml index d441ff6..f6378a7 100644 --- a/src/config/services.xml +++ b/src/config/services.xml @@ -18,6 +18,31 @@ + + %admin_locale% + + + + + + + + + + + + + + %admin_locale% + + + + + + + + + @@ -31,26 +56,17 @@ - + - + %admin_locale% - - %admin_locale% - + - + - - - - - - %admin_locale% -