fix logger service injection

This commit is contained in:
Mathieu Jaumotte 2021-02-12 16:39:33 +01:00
parent f4a76f659e
commit 5efb284c5b
2 changed files with 15 additions and 5 deletions

View File

@ -24,6 +24,7 @@ namespace Chill\ActivityBundle\Controller;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\PersonBundle\Privacy\PrivacyEvent;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -51,16 +52,25 @@ class ActivityController extends AbstractController
*/
protected $authorizationHelper;
/**
* @var LoggerInterface
*/
protected $logger;
/**
* ActivityController constructor.
*
* @param EventDispatcherInterface $eventDispatcher
* @param AuthorizationHelper $authorizationHelper
*/
public function __construct(EventDispatcherInterface $eventDispatcher, AuthorizationHelper $authorizationHelper)
{
public function __construct(
EventDispatcherInterface $eventDispatcher,
AuthorizationHelper $authorizationHelper,
LoggerInterface $logger
) {
$this->eventDispatcher = $eventDispatcher;
$this->authorizationHelper = $authorizationHelper;
$this->logger = $logger;
}
/**
@ -390,9 +400,8 @@ class ActivityController extends AbstractController
$form->handleRequest($request);
if ($form->isValid()) {
$logger = $this->get('chill.main.logger');
$logger->notice("An activity has been removed", array(
$this->logger->notice("An activity has been removed", array(
'by_user' => $this->getUser()->getUsername(),
'activity_id' => $activity->getId(),
'person_id' => $activity->getPerson()->getId(),

View File

@ -3,4 +3,5 @@ services:
arguments:
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
$logger: '@chill.main.logger'
tags: ['controller.service_arguments']