fixing any depreciations in fixtures feature

This commit is contained in:
2021-01-14 18:57:02 +01:00
parent 3d02785da2
commit e053bf999e
2 changed files with 34 additions and 19 deletions

View File

@@ -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
)));
}
}
}