fixing any depreciations in fixtures feature

This commit is contained in:
Mathieu Jaumotte 2021-01-14 18:57:02 +01:00
parent 3989c4faff
commit a0d36b8d78
2 changed files with 35 additions and 3 deletions

View File

@ -17,6 +17,7 @@
*/ */
namespace Chill\PersonBundle\DataFixtures\ORM; namespace Chill\PersonBundle\DataFixtures\ORM;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -29,6 +30,7 @@ use Chill\CustomFieldsBundle\CustomFields\CustomFieldText;
use Chill\CustomFieldsBundle\CustomFields\CustomFieldChoice; use Chill\CustomFieldsBundle\CustomFields\CustomFieldChoice;
use Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup; use Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Symfony\Contracts\Translation\TranslatorInterface;
/** /**
* *
@ -56,6 +58,30 @@ class LoadCustomFields extends AbstractFixture implements OrderedFixtureInterfac
*/ */
private $customFieldChoice; private $customFieldChoice;
/**
* @var TranslatableStringHelper
*/
private $translatableStringHelper;
/**
* @var TranslatorInterface
*/
private $translator;
/**
* LoadCustomFields constructor.
*
* @param TranslatableStringHelper $translatableStringHelper
* @param TranslatorInterface $translator
*/
public function __construct(
TranslatableStringHelper $translatableStringHelper,
TranslatorInterface $translator
) {
$this->translatableStringHelper = $translatableStringHelper;
$this->translator = $translator;
}
//put your code here //put your code here
public function getOrder() public function getOrder()
{ {
@ -112,16 +138,16 @@ class LoadCustomFields extends AbstractFixture implements OrderedFixtureInterfac
return new CustomFieldText( return new CustomFieldText(
$this->container->get('request_stack'), $this->container->get('request_stack'),
$this->container->get('templating'), $this->container->get('templating'),
$this->container->get('chill.main.helper.translatable_string') $this->translatableStringHelper
); );
} }
private function createCustomFieldChoice() private function createCustomFieldChoice()
{ {
return new CustomFieldChoice( return new CustomFieldChoice(
$this->container->get('translator.default'), $this->translator,
$this->container->get('templating'), $this->container->get('templating'),
$this->container->get('chill.main.helper.translatable_string') $this->translatableStringHelper
); );
} }

View File

@ -2,3 +2,9 @@ services:
Chill\PersonBundle\DataFixtures\ORM\: Chill\PersonBundle\DataFixtures\ORM\:
resource: ../../DataFixtures/ORM resource: ../../DataFixtures/ORM
tags: [ 'doctrine.fixture.orm' ] tags: [ 'doctrine.fixture.orm' ]
Chill\PersonBundle\DataFixtures\ORM\LoadCustomFields:
arguments:
$translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
$translator: '@Symfony\Component\Translation\TranslatorInterface'
tags: [ 'doctrine.fixture.orm' ]