3 namespace Rapsys\AirBundle\DataFixtures
;
5 use Doctrine\Bundle\FixturesBundle\Fixture
;
6 use Doctrine\Persistence\ObjectManager
;
7 use Symfony\Component\DependencyInjection\ContainerAwareInterface
;
8 use Symfony\Component\DependencyInjection\ContainerInterface
;
9 use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface
;
11 use Rapsys\AirBundle\Entity\Civility
;
12 use Rapsys\AirBundle\Entity\Group
;
13 use Rapsys\AirBundle\Entity\User
;
14 use Rapsys\AirBundle\Entity\Location
;
15 use Rapsys\AirBundle\Entity\Slot
;
17 class AirFixtures
extends Fixture
implements ContainerAwareInterface
{
19 * @var ContainerInterface
24 * @var UserPasswordHasherInterface
28 public function setContainer(ContainerInterface
$container = null) {
29 $this->container
= $container;
30 $this->hasher
= $this->container
->get('security.password_hasher_factory');
36 public function load(ObjectManager
$manager) {
38 $civilityTree = array(
46 foreach($civilityTree as $civilityData) {
47 $civility = new Civility();
48 $civility->setTitle($civilityData);
49 $civility->setCreated(new \
DateTime('now'));
50 $civility->setUpdated(new \
DateTime('now'));
51 $manager->persist($civility);
52 $civilitys[$civilityData] = $civility;
56 //TODO: insert countries from https://raw.githubusercontent.com/raramuridesign/mysql-country-list/master/country-lists/mysql-country-list-detailed-info.sql
57 #CREATE TABLE `countries` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `code` varchar(2) NOT NULL, `alpha` varchar(3) NOT NULL, `title` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL, `created` datetime NOT NULL, `updated` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `code` (`code`), UNIQUE KEY `alpha` (`alpha`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
58 #insert into countries (code, alpha, title, created, updated) select countryCode, isoAlpha3, countryName, NOW(), NOW() FROM apps_countries_detailed ORDER BY countryCode ASC, isoAlpha3 ASC;
62 'Argentine Tango' => [
63 'Milonga', 'Class and milonga', 'Public class', 'Private class'
69 foreach($danceTree as $danceTitle => $danceData) {
70 foreach($danceData as $danceType) {
71 $dance = new Dance($danceTitle, $danceType);
72 $dance->setCreated(new \
DateTime('now'));
73 $dance->setUpdated(new \
DateTime('now'));
74 $manager->persist($dance);
80 //XXX: ROLE_XXX is required by
91 foreach($groupTree as $groupData) {
92 $group = new Group($groupData);
93 $group->setCreated(new \
DateTime('now'));
94 $group->setUpdated(new \
DateTime('now'));
95 $manager->persist($group);
96 $groups[$groupData] = $group;
100 //Flush to get the ids
108 'mail' => 'tango@rapsys.eu',
109 'pseudonym' => 'Milonga Raphaël',
110 'forename' => 'Raphaël',
111 'surname' => 'Gertz',
112 'phone' => '+33677952829',
118 'mail' => 'denis.courvoisier@wanadoo.fr',
119 'pseudonym' => 'DJ Sined',
120 'forename' => 'Denis',
121 'surname' => 'Courvoisier',
122 'phone' => '+33600000000',
128 'mail' => 'rannou402@orange.fr',
129 'pseudonym' => 'Trio Tango',
130 'forename' => 'Michel',
131 'surname' => 'Rannou',
132 'phone' => '+33600000000',
137 'group' => 'Regular',
138 'mail' => 'roxmaps@gmail.com',
139 'pseudonym' => 'Roxana',
140 'forename' => 'Roxana',
141 'surname' => 'Prado',
142 'phone' => '+33600000000',
149 foreach($userTree as $userData) {
150 $user = new User($userData['mail']);
151 $user->setPseudonym($userData['pseudonym']);
152 $user->setForename($userData['forename']);
153 $user->setSurname($userData['surname']);
154 $user->setPhone($userData['phone']);
155 $user->setPassword($this->hasher
->hashPassword($user, $userData['password']));
156 $user->setCivility($civilitys[$userData['short']]);
157 $user->addGroup($groups[$userData['group']]);
158 $user->setCreated(new \
DateTime('now'));
159 $user->setUpdated(new \
DateTime('now'));
160 $manager->persist($user);
165 //Flush to get the ids
169 //XXX: adding a new zipcode here requires matching accuweather uris in Command/WeatherCommand.php
172 'title' => 'Garnier opera',
173 'short' => 'Garnier',
174 'address' => '10 Place de l\'Opéra',
175 'zipcode' => '75009',
177 'latitude' => 48.871268,
178 'longitude' => 2.331832,
182 'title' => 'Tino-Rossi garden',
184 'address' => '2 Quai Saint-Bernard',
185 'zipcode' => '75005',
187 'latitude' => 48.847736,
188 'longitude' => 2.360953,
192 'title' => 'Trocadero esplanade',
193 'short' => 'Trocadero',
194 'address' => '1 Avenue Hussein 1er de Jordanie',
195 #75016 pour meteo-france, accuweather supporte 75116
196 'zipcode' => '75116',
198 'latitude' => 48.861888,
199 'longitude' => 2.288853,
203 'title' => 'Colette place',
204 'short' => 'Colette',
205 'address' => 'Galerie du Théâtre Français',
206 'zipcode' => '75001',
208 'latitude' => 48.863219,
209 'longitude' => 2.335847,
213 'title' => 'Swan island',
215 'address' => 'Allée des Cygnes',
216 'zipcode' => '75015',
218 'latitude' => 48.849976, #48.849976
219 'longitude' => 2.279603, #2.2796029,
223 'title' => 'Jussieu esplanade',
224 'short' => 'Jussieu',
225 'address' => '25 rue des Fossés Saint-Bernard',
226 'zipcode' => '75005',
228 'latitude' => 48.847955, #48.8479548
229 'longitude' => 2.353291, #2.3532907,
233 'title' => 'Orleans gallery',
234 'short' => 'Orleans',
235 'address' => '8 Galerie du Jardin',
236 'zipcode' => '75001',
238 'latitude' => 48.863885,
239 'longitude' => 2.337387,
243 'title' => 'Orsay museum',
245 'address' => '1 rue de la Légion d\'Honneur',
246 'zipcode' => '75007',
248 'latitude' => 48.860418,
249 'longitude' => 2.325815,
253 'title' => 'Saint-Honore market',
255 'address' => '1 Passage des Jacobins',
256 'zipcode' => '75001',
258 'latitude' => 48.866992,
259 'longitude' => 2.331752,
263 'title' => 'Igor Stravinsky place',
264 'short' => 'Stravinsky',
265 'address' => '2 rue Brisemiche',
266 'zipcode' => '75004',
268 'latitude' => 48.859244,
269 'longitude' => 2.351289,
273 'title' => 'Tokyo palace',
275 'address' => '14 Avenue de New York',
276 'zipcode' => '75116',
278 'latitude' => 48.863827,
279 'longitude' => 2.297339,
283 'title' => 'Drawings\' garden',
284 'short' => 'Villette',
285 'address' => 'Allée du Belvédère',
286 'zipcode' => '75019',
288 'latitude' => 48.892503,
289 'longitude' => 2.389300,
293 'title' => 'Louvre palace',
295 'address' => 'Quai François Mitterrand',
296 'zipcode' => '75001',
298 'latitude' => 48.860386,
299 'longitude' => 2.332611,
303 'title' => 'Monde garden',
305 'address' => '63 avenue Pierre Mendès-France',
306 'zipcode' => '75013',
308 'latitude' => 48.840451,
309 'longitude' => 2.367638,
315 $locations = array();
316 foreach($locationTree as $locationData) {
317 $location = new Location();
318 $location->setTitle($locationData['title']);
319 $location->setShort($locationData['short']);
320 $location->setAddress($locationData['address']);
321 $location->setZipcode($locationData['zipcode']);
322 $location->setCity($locationData['city']);
323 $location->setLatitude($locationData['latitude']);
324 $location->setLongitude($locationData['longitude']);
325 $location->setHotspot($locationData['hotspot']);
326 $location->setCreated(new \
DateTime('now'));
327 $location->setUpdated(new \
DateTime('now'));
328 $manager->persist($location);
329 $locations[$locationData['title']] = $location;
333 //Flush to get the ids
346 foreach($slotTree as $slotData) {
348 $slot->setTitle($slotData);
349 $slot->setCreated(new \
DateTime('now'));
350 $slot->setUpdated(new \
DateTime('now'));
351 $manager->persist($slot);
352 $slots[$slot->getId()] = $slot;
356 //Flush to get the ids