Fix logger error

This commit is contained in:
Jean-Francois Monfort 2021-01-14 10:42:45 +01:00
parent 65a5c94c2f
commit 3989c4faff
2 changed files with 16 additions and 8 deletions

View File

@ -23,6 +23,7 @@
namespace Chill\PersonBundle\Controller;
use Chill\PersonBundle\Privacy\PrivacyEvent;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Form\PersonType;
@ -69,21 +70,27 @@ class PersonController extends Controller
* @var ConfigPersonAltNamesHelper
*/
protected $configPersonAltNameHelper;
public function __construct(
/**
* @var \Psr\Log\LoggerInterface
*/
private $logger;
public function __construct(
SimilarPersonMatcher $similarPersonMatcher,
TranslatorInterface $translator,
EventDispatcherInterface $eventDispatcher,
PersonRepository $personRepository,
ConfigPersonAltNamesHelper $configPersonAltNameHelper
ConfigPersonAltNamesHelper $configPersonAltNameHelper,
LoggerInterface $logger
) {
$this->similarPersonMatcher = $similarPersonMatcher;
$this->translator = $translator;
$this->eventDispatcher = $eventDispatcher;
$this->configPersonAltNameHelper = $configPersonAltNameHelper;
$this->personRepository = $personRepository;
}
$this->logger = $logger;
}
public function getCFGroup()
{
@ -296,10 +303,10 @@ class PersonController extends Controller
$person = $this->_bindCreationForm($form);
$errors = $this->_validatePersonAndAccompanyingPeriod($person);
$this->get('logger')->info(sprintf('Person created with %d errors ', count($errors)));
$this->logger->info(sprintf('Person created with %d errors ', count($errors)));
if ($errors->count() > 0) {
$this->get('logger')->info('The created person has errors');
$this->logger->info('The created person has errors');
$flashBag = $this->get('session')->getFlashBag();
$translator = $this->get('translator');
@ -321,7 +328,7 @@ class PersonController extends Controller
return $this->_renderNewForm($form);
} else {
$this->get('logger')->info('Person created without errors');
$this->logger->info('Person created without errors');
}
$alternatePersons = $this->similarPersonMatcher

View File

@ -6,6 +6,7 @@ services:
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
$personRepository: '@Chill\PersonBundle\Repository\PersonRepository'
$configPersonAltNameHelper: '@Chill\PersonBundle\Config\ConfigPersonAltNamesHelper'
$logger: '@Psr\Log\LoggerInterface'
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\TimelinePersonController: