3 namespace Rapsys\AirBundle\DataFixtures
;
5 use Rapsys\AirBundle\Entity\Title
;
6 use Rapsys\AirBundle\Entity\Group
;
7 use Rapsys\AirBundle\Entity\User
;
8 use Rapsys\AirBundle\Entity\Location
;
9 use Rapsys\AirBundle\Entity\Slot
;
11 class AirFixtures
extends \Doctrine\Bundle\FixturesBundle\Fixture
implements \Symfony\Component\DependencyInjection\ContainerAwareInterface
{
13 * @var ContainerInterface
17 public function setContainer(\Symfony\Component\DependencyInjection\ContainerInterface
$container = null)
19 $this->container
= $container;
25 public function load(\Doctrine\Common\Persistence\ObjectManager
$manager) {
26 $encoder = $this->container
->get('security.password_encoder');
37 foreach($titleTree as $shortData => $titleData) {
39 $title->setShort($shortData);
40 $title->setTitle($titleData);
41 $title->setCreated(new \
DateTime('now'));
42 $title->setUpdated(new \
DateTime('now'));
43 $manager->persist($title);
44 $titles[$shortData] = $title;
59 foreach($groupTree as $groupData) {
60 $group = new Group($groupData);
61 $group->setCreated(new \
DateTime('now'));
62 $group->setUpdated(new \
DateTime('now'));
63 $manager->persist($group);
64 $groups[$groupData] = $group;
68 //Flush to get the ids
75 'group' => 'ROLE_ADMIN',
76 'mail' => 'tango@rapsys.eu',
77 'pseudonym' => 'Rapsys',
78 'forename' => 'Raphaël',
80 'phone' => '+33677952829',
85 'group' => 'ROLE_SENIOR',
86 'mail' => 'rannou402@orange.fr',
87 'pseudonym' => 'Mitch',
88 'forename' => 'Michel',
89 'surname' => 'Rannou',
90 'phone' => '+33600000000',
95 'group' => 'ROLE_REGULAR',
96 'mail' => 'roxmaps@gmail.com',
97 'pseudonym' => 'Roxana',
98 'forename' => 'Roxana',
100 'phone' => '+33600000000',
105 'group' => 'ROLE_REGULAR',
106 'mail' => 'majid.ghedjatti@gmail.com',
107 'pseudonym' => 'El Guerrillero',
108 'forename' => 'Majid',
109 'surname' => 'Ghedjatti',
110 'phone' => '+33600000000',
115 'group' => 'ROLE_SENIOR',
116 'mail' => 'denis.courvoisier@wanadoo.fr',
117 'pseudonym' => 'Sined',
118 'forename' => 'Denis',
119 'surname' => 'Courvoisier',
120 'phone' => '+33600000000',
125 'group' => 'ROLE_REGULAR',
126 'mail' => 'kastango13@gmail.com',
127 'pseudonym' => 'Kastrat',
128 'forename' => 'Kastrat',
129 'surname' => 'Hasaj',
130 'phone' => '+33600000000',
137 foreach($userTree as $userData) {
139 $user->setMail($userData['mail']);
140 $user->setPseudonym($userData['pseudonym']);
141 $user->setForename($userData['forename']);
142 $user->setSurname($userData['surname']);
143 $user->setPhone($userData['phone']);
144 $user->setPassword($encoder->encodePassword($user, $userData['password']));
145 $user->setActive(true);
146 $user->setTitle($titles[$userData['short']]);
147 $user->addGroup($groups[$userData['group']]);
148 $user->setCreated(new \
DateTime('now'));
149 $user->setUpdated(new \
DateTime('now'));
150 $manager->persist($user);
155 //Flush to get the ids
161 'title' => 'Opéra Garnier',
162 'address' => '10 Place de l\'Opéra',
163 'zipcode' => '75009',
165 'latitude' => 48.871268,
166 'longitude' => 2.331832
169 'title' => 'Jardin Tino-Rossi',
170 'address' => '2 Quai Saint-Bernard',
171 'zipcode' => '75005',
173 'latitude' => 48.847736,
174 'longitude' => 2.360953
177 'title' => 'Esplanade du Trocadéro',
178 'address' => '1 Avenue Hussein 1er de Jordanie',
179 #75016 pour meteo-france, accuweather supporte 75116
180 'zipcode' => '75116',
182 'latitude' => 48.861888,
183 'longitude' => 2.288853
186 'title' => 'Marché Saint Honoré',
187 'address' => '1 Passage des Jacobins',
188 'zipcode' => '75001',
190 'latitude' => 48.866992,
191 'longitude' => 2.331752
194 'title' => 'Palais de Tokyo',
195 'address' => '14 Avenue de New York',
196 'zipcode' => '75116',
198 'latitude' => 48.863827,
199 'longitude' => 2.297339
204 $locations = array();
205 foreach($locationTree as $locationData) {
206 $location = new Location();
207 $location->setTitle($locationData['title']);
208 $location->setAddress($locationData['address']);
209 $location->setZipcode($locationData['zipcode']);
210 $location->setCity($locationData['city']);
211 $location->setLatitude($locationData['latitude']);
212 $location->setLongitude($locationData['longitude']);
213 $location->setCreated(new \
DateTime('now'));
214 $location->setUpdated(new \
DateTime('now'));
215 $manager->persist($location);
216 $locations[$locationData['title']] = $location;
220 //Flush to get the ids
226 'begin' => '14:00:00 UTC',
227 'length' => '05:00:00'
230 'begin' => '19:00:00 UTC',
231 'length' => '06:00:00'
234 'begin' => '19:00:00 UTC',
235 'length' => '07:00:00'
241 foreach($slotTree as $slotData) {
243 $slot->setBegin(new \
DateTime($slotData['begin']));
244 $slot->setLength(new \
DateTime($slotData['length']));
245 $slot->setCreated(new \
DateTime('now'));
246 $slot->setUpdated(new \
DateTime('now'));
247 $manager->persist($slot);
248 $slots[$slot->getId()] = $slot;
252 //Flush to get the ids