fix logger service dependency injection

This commit is contained in:
Mathieu Jaumotte 2021-03-04 16:13:34 +01:00
parent 84347ec982
commit b49264aec4
2 changed files with 23 additions and 2 deletions

View File

@ -21,6 +21,7 @@ namespace Chill\EventBundle\Controller;
use ArrayIterator;
use Chill\EventBundle\Entity\Event;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@ -39,6 +40,21 @@ use Symfony\Component\Form\Extension\Core\Type\CollectionType;
class ParticipationController extends AbstractController
{
/**
* @var \Psr\Log\LoggerInterface
*/
private $logger;
/**
* ParticipationController constructor.
*
* @param LoggerInterface $logger
*/
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}
/**
* Show a form to add a participation
*
@ -56,7 +72,7 @@ class ParticipationController extends AbstractController
try {
$this->testRequest($request);
} catch (\RuntimeException $ex) {
$this->get('logger')->warning($ex->getMessage());
$this->logger->warning($ex->getMessage());
return (new Response())
->setStatusCode(Response::HTTP_BAD_REQUEST)
@ -234,7 +250,7 @@ class ParticipationController extends AbstractController
try {
$this->testRequest($request);
} catch (\RuntimeException $ex) {
$this->get('logger')->warning($ex->getMessage());
$this->logger->warning($ex->getMessage());
return (new Response())
->setStatusCode(Response::HTTP_BAD_REQUEST)

View File

@ -8,4 +8,9 @@ services:
$translator: '@Symfony\Component\Translation\TranslatorInterface'
$paginator: '@chill_main.paginator_factory'
public: true
tags: ['controller.service_arguments']
Chill\EventBundle\Controller\ParticipationController:
arguments:
$logger: '@Psr\Log\LoggerInterface'
tags: ['controller.service_arguments']