mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
resolving deprecated private service injection on commands classes
This commit is contained in:
parent
a0d36b8d78
commit
f63c4b42e0
@ -19,7 +19,10 @@
|
|||||||
|
|
||||||
namespace Chill\PersonBundle\Command;
|
namespace Chill\PersonBundle\Command;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
@ -36,6 +39,7 @@ use Chill\CustomFieldsBundle\Service\CustomFieldProvider;
|
|||||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\EventDispatcher\Event;
|
use Symfony\Component\EventDispatcher\Event;
|
||||||
|
use Symfony\Component\Form\FormFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ImportPeopleFromCSVCommand
|
* Class ImportPeopleFromCSVCommand
|
||||||
@ -43,7 +47,7 @@ use Symfony\Component\EventDispatcher\Event;
|
|||||||
* @package Chill\PersonBundle\Command
|
* @package Chill\PersonBundle\Command
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class ImportPeopleFromCSVCommand extends ContainerAwareCommand
|
class ImportPeopleFromCSVCommand extends Command
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var InputInterface
|
* @var InputInterface
|
||||||
@ -125,18 +129,35 @@ class ImportPeopleFromCSVCommand extends ContainerAwareCommand
|
|||||||
*/
|
*/
|
||||||
protected static $defaultDateInterpreter = "%d/%m/%Y|%e/%m/%y|%d/%m/%Y|%e/%m/%Y";
|
protected static $defaultDateInterpreter = "%d/%m/%Y|%e/%m/%y|%d/%m/%Y|%e/%m/%Y";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var FormFactory
|
||||||
|
*/
|
||||||
|
protected $formFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ImportPeopleFromCSVCommand constructor.
|
||||||
|
*
|
||||||
|
* @param LoggerInterface $logger
|
||||||
|
* @param TranslatableStringHelper $helper
|
||||||
|
* @param EntityManagerInterface $em
|
||||||
|
* @param CustomFieldProvider $customFieldProvider
|
||||||
|
* @param EventDispatcherInterface $eventDispatcher
|
||||||
|
* @param FormFactory $formFactory
|
||||||
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
\Psr\Log\LoggerInterface $logger,
|
LoggerInterface $logger,
|
||||||
\Chill\MainBundle\Templating\TranslatableStringHelper $helper,
|
TranslatableStringHelper $helper,
|
||||||
\Doctrine\ORM\EntityManagerInterface $em,
|
EntityManagerInterface $em,
|
||||||
CustomFieldProvider $customFieldProvider,
|
CustomFieldProvider $customFieldProvider,
|
||||||
EventDispatcherInterface $eventDispatcher
|
EventDispatcherInterface $eventDispatcher,
|
||||||
|
FormFactory $formFactory
|
||||||
) {
|
) {
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->helper = $helper;
|
$this->helper = $helper;
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->customFieldProvider = $customFieldProvider;
|
$this->customFieldProvider = $customFieldProvider;
|
||||||
$this->eventDispatcher = $eventDispatcher;
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
|
$this->formFactory = $formFactory;
|
||||||
|
|
||||||
parent::__construct('chill:person:import');
|
parent::__construct('chill:person:import');
|
||||||
}
|
}
|
||||||
@ -393,9 +414,6 @@ EOF
|
|||||||
$this->logger->debug("Setting locale to ".$input->getArgument('locale'));
|
$this->logger->debug("Setting locale to ".$input->getArgument('locale'));
|
||||||
setlocale(LC_TIME, $input->getArgument('locale'));
|
setlocale(LC_TIME, $input->getArgument('locale'));
|
||||||
|
|
||||||
/* @var $em \Doctrine\Persistence\ObjectManager */
|
|
||||||
$this->em = $this->getContainer()->get('doctrine.orm.entity_manager');
|
|
||||||
|
|
||||||
// opening csv as resource
|
// opening csv as resource
|
||||||
$csv = $this->openCSV();
|
$csv = $this->openCSV();
|
||||||
|
|
||||||
@ -857,15 +875,14 @@ EOF
|
|||||||
*/
|
*/
|
||||||
protected function processingCustomFields(Person $person, $row)
|
protected function processingCustomFields(Person $person, $row)
|
||||||
{
|
{
|
||||||
/* @var $factory \Symfony\Component\Form\FormFactory */
|
|
||||||
$factory = $this->getContainer()->get('form.factory');
|
|
||||||
/* @var $cfProvider \Chill\CustomFieldsBundle\Service\CustomFieldProvider */
|
/* @var $cfProvider \Chill\CustomFieldsBundle\Service\CustomFieldProvider */
|
||||||
$cfProvider = $this->customFieldProvider;
|
$cfProvider = $this->customFieldProvider;
|
||||||
$cfData = array();
|
$cfData = array();
|
||||||
|
|
||||||
/* @var $$customField \Chill\CustomFieldsBundle\Entity\CustomField */
|
/* @var $$customField \Chill\CustomFieldsBundle\Entity\CustomField */
|
||||||
foreach($this->customFieldMapping as $rowNumber => $customField) {
|
foreach($this->customFieldMapping as $rowNumber => $customField) {
|
||||||
$builder = $factory->createBuilder();
|
$builder = $this->formFactory->createBuilder();
|
||||||
$cfProvider->getCustomFieldByType($customField->getType())
|
$cfProvider->getCustomFieldByType($customField->getType())
|
||||||
->buildForm($builder, $customField);
|
->buildForm($builder, $customField);
|
||||||
$form = $builder->getForm();
|
$form = $builder->getForm();
|
||||||
|
@ -1,14 +1,4 @@
|
|||||||
services:
|
services:
|
||||||
Chill\PersonBundle\Command\ImportPeopleFromCSVCommand:
|
|
||||||
arguments:
|
|
||||||
$logger: '@logger'
|
|
||||||
$helper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
|
|
||||||
$em: '@Doctrine\ORM\EntityManagerInterface'
|
|
||||||
$customFieldProvider: '@Chill\CustomFieldsBundle\Service\CustomFieldProvider'
|
|
||||||
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
|
|
||||||
tags:
|
|
||||||
- { name: console.command }
|
|
||||||
|
|
||||||
Chill\PersonBundle\Command\ChillPersonMoveCommand:
|
Chill\PersonBundle\Command\ChillPersonMoveCommand:
|
||||||
arguments:
|
arguments:
|
||||||
$em: '@Doctrine\ORM\EntityManagerInterface'
|
$em: '@Doctrine\ORM\EntityManagerInterface'
|
||||||
@ -16,3 +6,14 @@ services:
|
|||||||
$chillLogger: '@chill.main.logger'
|
$chillLogger: '@chill.main.logger'
|
||||||
tags:
|
tags:
|
||||||
- { name: console.command }
|
- { name: console.command }
|
||||||
|
|
||||||
|
Chill\PersonBundle\Command\ImportPeopleFromCSVCommand:
|
||||||
|
arguments:
|
||||||
|
$logger: '@logger'
|
||||||
|
$helper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
|
||||||
|
$em: '@Doctrine\ORM\EntityManagerInterface'
|
||||||
|
$customFieldProvider: '@Chill\CustomFieldsBundle\Service\CustomFieldProvider'
|
||||||
|
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
|
||||||
|
$formFactory: '@form.factory'
|
||||||
|
tags:
|
||||||
|
- { name: console.command }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user