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');
31 'Mlle' => 'Mademoiselle',
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;
57 foreach($groupTree as $groupData) {
58 $group = new Group($groupData);
59 $group->setCreated(new \
DateTime('now'));
60 $group->setUpdated(new \
DateTime('now'));
61 $manager->persist($group);
62 $groups[$groupData] = $group;
66 //Flush to get the ids
73 'group' => 'ROLE_SUPER',
74 'mail' => 'airlibre@rapsys.eu',
75 'pseudonym' => 'Rapsys',
76 'forename' => 'Raphaël',
82 'group' => 'ROLE_ADMIN',
83 'mail' => 'rannou402@orange.fr',
84 'pseudonym' => 'Mitch',
85 'forename' => 'Michel',
86 'surname' => 'Rannou',
91 'group' => 'ROLE_ADMIN',
92 'mail' => 'roxmaps@gmail.com',
93 'pseudonym' => 'Roxana',
94 'forename' => 'Roxana',
100 'group' => 'ROLE_ADMIN',
101 'mail' => 'majid.ghedjatti@gmail.com',
102 'pseudonym' => 'El Guerrillero',
103 'forename' => 'Majid',
104 'surname' => 'Ghedjatti',
109 'group' => 'ROLE_ADMIN',
110 'mail' => 'denis.courvoisier@wanadoo.fr',
111 'pseudonym' => 'Sined',
112 'forename' => 'Denis',
113 'surname' => 'Courvoisier',
118 'group' => 'ROLE_ADMIN',
119 'mail' => 'kastango13@gmail.com',
120 'pseudonym' => 'Kastrat',
121 'forename' => 'Kastrat',
122 'surname' => 'Hasaj',
129 foreach($userTree as $userData) {
131 $user->setMail($userData['mail']);
132 $user->setPseudonym($userData['pseudonym']);
133 $user->setForename($userData['forename']);
134 $user->setSurname($userData['surname']);
135 $user->setPassword($encoder->encodePassword($user, $userData['password']));
136 $user->setActive(true);
137 $user->setTitle($titles[$userData['short']]);
138 $user->addGroup($groups[$userData['group']]);
139 $user->setCreated(new \
DateTime('now'));
140 $user->setUpdated(new \
DateTime('now'));
141 $manager->persist($user);
146 //Flush to get the ids
152 'title' => 'Esplanade du Trocadéro',
153 'address' => '1 Avenue Hussein 1er de Jordanie',
154 #75016 pour meteo-france, accuweather supporte 75116
155 'zipcode' => '75116',
157 'latitude' => 48.8619,
158 'longitude' => 2.2888
161 'title' => 'Opéra Garnier',
162 'address' => 'Place de l\'Opéra',
163 'zipcode' => '75009',
165 'latitude' => 48.871365,
166 'longitude' => 2.332026
169 'title' => 'Marché Saint Honoré',
170 'address' => '1 Passage des Jacobins',
171 'zipcode' => '75001',
173 'latitude' => 48.8668,
174 'longitude' => 2.331659
177 'title' => 'Jardin Tino-Rossi',
178 'address' => '2 Quai Saint-Bernard',
179 'zipcode' => '75005',
181 'latitude' => 48.847736,
182 'longitude' => 2.360953
185 'title' => 'Palais de Tokyo',
186 'address' => '13 Avenue du Président Wilson',
187 'zipcode' => '75116',
189 'latitude' => 48.864567,
190 'longitude' => 2.296892
195 $locations = array();
196 foreach($locationTree as $locationData) {
197 $location = new Location();
198 $location->setTitle($locationData['title']);
199 $location->setAddress($locationData['address']);
200 $location->setZipcode($locationData['zipcode']);
201 $location->setCity($locationData['city']);
202 $location->setLatitude($locationData['latitude']);
203 $location->setLongitude($locationData['longitude']);
204 $location->setCreated(new \
DateTime('now'));
205 $location->setUpdated(new \
DateTime('now'));
206 $manager->persist($location);
207 $locations[$locationData['title']] = $location;
211 //Flush to get the ids
217 'begin' => '14:00:00 UTC',
218 'end' => '19:00:00 UTC'
221 'begin' => '19:00:00 UTC',
222 'end' => '23:00:00 UTC'
225 'begin' => '23:00:00 UTC',
226 'end' => '02:00:00 UTC'
232 foreach($slotTree as $slotData) {
234 $slot->setBegin(new \
DateTime($slotData['begin']));
235 $slot->setEnd(new \
DateTime($slotData['end']));
236 $slot->setCreated(new \
DateTime('now'));
237 $slot->setUpdated(new \
DateTime('now'));
238 $manager->persist($slot);
239 $slots[$slot->getId()] = $slot;
243 //Flush to get the ids