resolving deprecated private service injection on commands classes

This commit is contained in:
2021-01-26 13:47:35 +01:00
parent f162ed3911
commit b45191bd04
8 changed files with 168 additions and 34 deletions

View File

@@ -1,7 +1,8 @@
<?php
namespace Chill\MainBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Intl\Intl;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -11,9 +12,29 @@ use Symfony\Component\Console\Output\OutputInterface;
* @author Julien Fastré <julien.fastre@champs-libres.coop
*
*/
class LoadCountriesCommand extends ContainerAwareCommand
class LoadCountriesCommand extends Command
{
/**
* @var EntityManager
*/
private $entityManager;
private $availableLanguages;
/**
* LoadCountriesCommand constructor.
*
* @param EntityManager $entityManager
* @param $availableLanguages
*/
public function __construct(EntityManager $entityManager, $availableLanguages)
{
$this->entityManager=$entityManager;
$this->availableLanguages=$availableLanguages;
parent::__construct();
}
/*
* (non-PHPdoc)
* @see \Symfony\Component\Console\Command\Command::configure()
@@ -31,8 +52,8 @@ class LoadCountriesCommand extends ContainerAwareCommand
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$countries = static::prepareCountryList($this->getContainer()->getParameter('chill_main.available_languages'));
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
$countries = static::prepareCountryList($this->availableLanguages);
$em = $this->entityManager;
foreach($countries as $country) {
$countryStored = $em->getRepository('ChillMainBundle:Country')