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

View File

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