fix logger service dependency injection

This commit is contained in:
Mathieu Jaumotte 2021-03-04 16:13:34 +01:00
parent cedf08b906
commit 2c35fb1e5b
2 changed files with 24 additions and 3 deletions

View File

@ -2,6 +2,7 @@
namespace Chill\MainBundle\Controller;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
@ -21,7 +22,22 @@ class UserController extends AbstractController
{
const FORM_GROUP_CENTER_COMPOSED = 'composed_groupcenter';
/**
* @var \Psr\Log\LoggerInterface
*/
private $logger;
/**
* UserController constructor.
*
* @param LoggerInterface $logger
*/
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}
/**
* Lists all User entities.
*
@ -363,7 +379,7 @@ class UserController extends AbstractController
$password = $editForm->get('new_password')->getData();
// logging for prod
$this->get('logger')->info('update password for an user', [
$this->logger->info('update password for an user', [
'by' => $this->getUser()->getUsername(),
'user' => $user->getUsername()
]);

View File

@ -20,8 +20,13 @@ services:
Chill\MainBundle\Controller\PermissionsGroupController:
arguments:
$translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
$translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
$roleProvider: '@chill.main.role_provider'
$roleHierarchy: '@security.role_hierarchy'
$translator: '@Symfony\Contracts\Translation\TranslatorInterface'
tags: ['controller.service_arguments']
Chill\MainBundle\Controller\UserController:
arguments:
$logger: '@Psr\Log\LoggerInterface'
tags: ['controller.service_arguments']