Completed
Push — Recipes ( 43b996...9c2236 )
by Laurent
03:16
created

LoadArticleData::getDependencies()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * LoadArticleData Données de l'application GLSR.
4
 *
5
 * PHP Version 7
6
 *
7
 * @author    Quétier Laurent <[email protected]>
8
 * @copyright 2018 Dev-Int GLSR
9
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
10
 *
11
 * @version GIT: $Id$
12
 *
13
 * @see https://github.com/Dev-Int/glsr
14
 */
15
16
namespace App\DataFixtures;
17
18
use Doctrine\Bundle\FixturesBundle\Fixture;
19
use Doctrine\Common\Persistence\ObjectManager;
20
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
21
use App\Entity\Settings\Article;
22
use App\Entity\Settings\Diverse\Material;
23
use App\DataFixtures\LoadDiverseData;
24
use App\DataFixtures\LoadSupplierData;
25
26
/**
27
 * Load Article Data.
28
 *
29
 * @category DataFixtures
30
 */
31
class LoadArticleData extends Fixture implements DependentFixtureInterface
32
{
33
    /**
34
     * Load data fixtures with the passed EntityManager.
35
     *
36
     * @param ObjectManager $manager
37
     */
38
    public function load(ObjectManager $manager)
39
    {
40
        /**
41
         * Supplier references
42
         */
43
        $davigel = $this->getReference('supplier1');
44
        $davifrais = $this->getReference('supplier2');
45
        $davisec = $this->getReference('supplier3');
46
        $loireBoissons = $this->getReference('supplier4');
47
48
        /**
49
         * Categories references
50
         */
51
        $surgele = $this->getReference('family-log3');
0 ignored issues
show
Unused Code introduced by
The assignment to $surgele is dead and can be removed.
Loading history...
52
        $frais = $this->getReference('family-log4');
53
        $sec = $this->getReference('family-log5');
54
        $boissons = $this->getReference('family-log6');
0 ignored issues
show
Unused Code introduced by
The assignment to $boissons is dead and can be removed.
Loading history...
55
        $fruitLegumesSurgele = $this->getReference('family-log7');
0 ignored issues
show
Unused Code introduced by
The assignment to $fruitLegumesSurgele is dead and can be removed.
Loading history...
56
        $patisseriesSurgele = $this->getReference('family-log8');
0 ignored issues
show
Unused Code introduced by
The assignment to $patisseriesSurgele is dead and can be removed.
Loading history...
57
        $viandeSurgele = $this->getReference('family-log9');
58
        $fruitLegumesFrais = $this->getReference('family-log10');
59
        $patisseriesFrais = $this->getReference('family-log11');
0 ignored issues
show
Unused Code introduced by
The assignment to $patisseriesFrais is dead and can be removed.
Loading history...
60
        $viandeFrais = $this->getReference('family-log12');
0 ignored issues
show
Unused Code introduced by
The assignment to $viandeFrais is dead and can be removed.
Loading history...
61
        $fruitLegumesSec = $this->getReference('family-log13');
0 ignored issues
show
Unused Code introduced by
The assignment to $fruitLegumesSec is dead and can be removed.
Loading history...
62
        $patisseriesSec = $this->getReference('family-log14');
0 ignored issues
show
Unused Code introduced by
The assignment to $patisseriesSec is dead and can be removed.
Loading history...
63
        $bieres = $this->getReference('family-log15');
0 ignored issues
show
Unused Code introduced by
The assignment to $bieres is dead and can be removed.
Loading history...
64
        $vins = $this->getReference('family-log16');
65
66
        /**
67
         * Storage area references
68
         */
69
        $zoneSurgele = $this->getReference('zoneStorage1');
70
        $zoneFrais = $this->getReference('zoneStorage2');
71
        $zoneSec = $this->getReference('zoneStorage3');
72
        $zoneBoisson = $this->getReference('zoneStorage4');
73
74
        /**
75
         * Units references
76
         */
77
        $boite = $this->getReference('unit1');
0 ignored issues
show
Unused Code introduced by
The assignment to $boite is dead and can be removed.
Loading history...
78
        $bouteille = $this->getReference('unit2');
79
        $carton = $this->getReference('unit3');
0 ignored issues
show
Unused Code introduced by
The assignment to $carton is dead and can be removed.
Loading history...
80
        $colis = $this->getReference('unit4');
0 ignored issues
show
Unused Code introduced by
The assignment to $colis is dead and can be removed.
Loading history...
81
        $kilogramme = $this->getReference('unit5');
82
        $litre = $this->getReference('unit6');
0 ignored issues
show
Unused Code introduced by
The assignment to $litre is dead and can be removed.
Loading history...
83
        $piece = $this->getReference('unit7');
84
85
        /**
86
         * VAT references
87
         */
88
        $tvaReduit = $this->getReference('tva1');
89
        $tvaMoyen = $this->getReference('tva2');
0 ignored issues
show
Unused Code introduced by
The assignment to $tvaMoyen is dead and can be removed.
Loading history...
90
        $tvaLuxe = $this->getReference('tva3');
0 ignored issues
show
Unused Code introduced by
The assignment to $tvaLuxe is dead and can be removed.
Loading history...
91
92
        /**
93
         * Articles datas
94
         */
95
        $datas = [
96
            ['name' => 'Salade', 'supplier' => $davifrais,
97
            'familyLog' => $fruitLegumesFrais, 'zoneStorage' => $zoneFrais,
98
            'unitStorage' => $piece, 'unitWorking' => $kilogramme, 'price' => 2.99,
99
            'packaging' => 12.0, 'tva' => $tvaReduit, 'minStock' => 2.0, ],
100
            ['name' => 'Bavette 150gr', 'supplier' => $davigel,
101
            'familyLog' => $viandeSurgele, 'zoneStorage' => $zoneSurgele,
102
            'unitStorage' => $piece, 'unitWorking' => $piece, 'price' => 2.99,
103
            'packaging' => 28, 'tva' => $tvaReduit, 'minStock' => 2.0, ],
104
            ['name' => 'Baguettine', 'supplier' => $davigel,
105
            'familyLog' => $viandeSurgele, 'zoneStorage' => $zoneSurgele,
106
            'unitStorage' => $piece, 'unitWorking' => $piece, 'price' => 15.2,
107
            'packaging' => 90.0, 'tva' => $tvaReduit, 'minStock' => 20.0, ],
108
            ['name' => 'Steack haché 20%MG 120g', 'supplier' => $davigel,
109
            'familyLog' => $viandeSurgele, 'zoneStorage' => $zoneSurgele,
110
            'unitStorage' => $piece, 'unitWorking' => $piece, 'price' => 1.22,
111
            'packaging' => 50.0, 'tva' => $tvaReduit, 'minStock' => 12.0, ],
112
            ['name' => 'Ananas poche 2.3 KG', 'supplier' => $davisec,
113
            'familyLog' => $sec, 'zoneStorage' => $zoneSec,
114
            'unitStorage' => $piece, 'unitWorking' => $kilogramme, 'price' => 4.05,
115
            'packaging' => 4, 'tva' => $tvaReduit, 'minStock' => 3.0, ],
116
            ['name' => 'Appareil Champigons 2 KG', 'supplier' => $davifrais,
117
            'familyLog' => $frais, 'zoneStorage' => $zoneFrais,
118
            'unitStorage' => $piece, 'unitWorking' => $kilogramme, 'price' => 6.39,
119
            'packaging' => 4.0, 'tva' => $tvaReduit, 'minStock' => 2.0, ],
120
            ['name' => 'Bacon tranche Barq 88G', 'supplier' => $davifrais,
121
            'familyLog' => $frais, 'zoneStorage' => $zoneFrais,
122
            'unitStorage' => $piece, 'unitWorking' => $kilogramme, 'price' => 0.75,
123
            'packaging' => 6.0, 'tva' => $tvaReduit, 'minStock' => 2, ],
124
            ['name' => 'Beurre doux 8Gx125', 'supplier' => $davifrais,
125
            'familyLog' => $frais, 'zoneStorage' => $zoneFrais,
126
            'unitStorage' => $kilogramme, 'unitWorking' => $piece, 'price' => 6.83,
127
            'packaging' => 1.0, 'tva' => $tvaReduit, 'minStock' => 0.5, ],
128
            ['name' => 'Boule pour oeuf neige', 'supplier' => $davifrais,
129
            'familyLog' => $frais, 'zoneStorage' => $zoneFrais,
130
            'unitStorage' => $piece, 'unitWorking' => $piece, 'price' => 1.75,
131
            'packaging' => 6.0, 'tva' => $tvaReduit, 'minStock' => 2.0, ],
132
            ['name' => 'Champignons émincé 500G', 'supplier' => $davifrais,
133
            'familyLog' => $fruitLegumesFrais, 'zoneStorage' => $zoneFrais,
134
            'unitStorage' => $kilogramme, 'unitWorking' => $kilogramme,
135
            'price' => 3.17, 'packaging' => 3.5, 'tva' => $tvaReduit,
136
            'minStock' => 1.0, ],
137
            ['name' => 'Chorizo prétr. 500G', 'supplier' => $davifrais,
138
            'familyLog' => $fruitLegumesFrais, 'zoneStorage' => $zoneFrais,
139
            'unitStorage' => $kilogramme, 'unitWorking' => $kilogramme,
140
            'price' => 5.11, 'packaging' => 6, 'tva' => $tvaReduit, 'minStock' => 1.0, ],
141
            ['name' => 'V.RG Bourgueil 75cl', 'supplier' => $loireBoissons,
142
            'familyLog' => $vins, 'zoneStorage' => $zoneBoisson,
143
            'unitStorage' => $bouteille, 'unitWorking' => $bouteille,
144
            'price' => 5.11, 'packaging' => 6.0, 'tva' => $tvaReduit, 'minStock' => 3.0, ],
145
        ];
146
147
        foreach ($datas as $key => $data) {
148
            $article = new Article();
149
            $article->setName($data['name'])
150
                ->setSupplier($data['supplier'])
151
                ->setFamilyLog($data['familyLog'])
152
                ->addZoneStorage($data['zoneStorage'])
153
                ->setUnitStorage($data['unitStorage'])
154
                ->setUnitWorking($data['unitWorking'])
155
                ->setPrice($data['price'])
156
                ->setPackaging($data['packaging'])
157
                ->setTva($data['tva'])
158
                ->setMinStock($data['minStock']);
159
160
            $manager->persist($article);
161
            $order = $key + 1;
162
            $this->addReference('article'.$order, $article);
163
164
            $material = new Material();
165
            $material->setName($data['name'])
166
                ->setUnitWorking($data['unitWorking'])
167
                ->addArticle($this->getReference('article'.$order))
168
                ->setActive(1);
169
170
            $manager->persist($material);
171
            $this->addReference('material'.$order, $material);
172
        }
173
174
        $manager->flush();
175
    }
176
177
    public function getDependencies()
178
    {
179
        return [
180
            LoadDiverseData::class,
181
            LoadSupplierData::class,
182
        ];
183
    }
184
}
185