From e053bf999efa63f3d9e5234d015185d93913b03d Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 14 Jan 2021 18:57:02 +0100 Subject: [PATCH] fixing any depreciations in fixtures feature --- CustomFields/CustomFieldChoice.php | 13 +++++++--- DataFixtures/ORM/LoadOption.php | 40 ++++++++++++++++++------------ 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/CustomFields/CustomFieldChoice.php b/CustomFields/CustomFieldChoice.php index 17012ecd1..eaf423b7c 100644 --- a/CustomFields/CustomFieldChoice.php +++ b/CustomFields/CustomFieldChoice.php @@ -30,9 +30,9 @@ use Symfony\Component\HttpFoundation\RequestStack; use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldDataTransformer; use Symfony\Bridge\Twig\TwigEngine; use Chill\MainBundle\Templating\TranslatableStringHelper; -use Symfony\Component\Translation\Translator; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Chill\MainBundle\Form\Type\TranslatableStringFormType; +use Symfony\Contracts\Translation\TranslatorInterface; /** * @@ -60,9 +60,16 @@ class CustomFieldChoice extends AbstractCustomField * @var TranslatableStringHelper Helper that find the string in current locale from an array of translation */ private $translatableStringHelper; - + + /** + * CustomFieldChoice constructor. + * + * @param TranslatorInterface $translator + * @param TwigEngine $templating + * @param TranslatableStringHelper $translatableStringHelper + */ public function __construct( - Translator $translator, + TranslatorInterface $translator, TwigEngine $templating, TranslatableStringHelper $translatableStringHelper) { diff --git a/DataFixtures/ORM/LoadOption.php b/DataFixtures/ORM/LoadOption.php index e181dea5d..6bb894031 100644 --- a/DataFixtures/ORM/LoadOption.php +++ b/DataFixtures/ORM/LoadOption.php @@ -66,10 +66,23 @@ class LoadOption extends AbstractFixture implements OrderedFixtureInterface public function load(ObjectManager $manager) { echo "Loading Options \n"; - // load companies - $this->loadingCompanies($manager); - $this->loadingWords($manager); + // load companies + + /* + * TODO sf4 - disabled to avoid error : + * + * An exception occurred while executing 'INSERT INTO custom_field_long_choice_options (id, key, text, internal_key, active, parent_id) + * VALUES (?, ?, ?, ?, ?, ?)' with params [1153, "company", {"fr":"Grandes Entreprises","nl":"Grotes Bedrijven","en":"Big Companies"}, "", 1, null]: + * + * SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type json + * DETAIL: Token "Array" is invalid. + * CONTEXT: JSON data, line 1: Array + * + */ + + //$this->loadingCompanies($manager); + //$this->loadingWords($manager); $manager->flush(); @@ -98,6 +111,7 @@ class LoadOption extends AbstractFixture implements OrderedFixtureInterface ->setKey('word') ; $manager->persist($parent); + //Load children $expected_nb_children = rand(10, 50); for ($i=0; $i < $expected_nb_children; $i++) { @@ -111,7 +125,7 @@ class LoadOption extends AbstractFixture implements OrderedFixtureInterface } private function loadingCompanies(\Doctrine\Persistence\ObjectManager $manager) - { + { echo "Loading companies \n"; $companiesParents = array( array( @@ -134,32 +148,26 @@ class LoadOption extends AbstractFixture implements OrderedFixtureInterface foreach ($companiesParents as $text) { - // sf4 check: erreur non résolue ici avec $text: In PDOStatement.php line 81: Notice: Array to string conversion - // - // et avec error_reporting(0): - - // An exception occurred while executing 'INSERT INTO custom_field_long_choice_options (id, key, text, internal_key, active, parent_id) VALUES (?, ?, ?, ?, ?, ?)' with params [1304, "company", { - // "fr":"Grandes Entreprises","nl":"Grotes Bedrijven","en":"Big Companies"}, "", 1, null]: - // - // SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type json - // DETAIL: Token "Array" is invalid. - // CONTEXT: JSON data, line 1: Array - $parent = (new Option()) ->setText($text) ->setKey('company') ; $manager->persist($parent); + //Load children $expected_nb_children = rand(10, 50); for ($i=0; $i < $expected_nb_children; $i++) { + $companyName = $this->fakerFr->company; - $manager->persist($this->createChildOption($parent, array( + + $manager->persist( + $this->createChildOption($parent, array( 'fr' => $companyName, 'nl' => $companyName, 'en' => $companyName ))); } + } }