1 <?php
declare(strict_types
=1);
4 * This file is part of the Rapsys AirBundle package.
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Rapsys\AirBundle\DataFixtures
;
14 use Doctrine\Bundle\FixturesBundle\Fixture
;
15 use Doctrine\Persistence\ObjectManager
;
16 use Symfony\Component\DependencyInjection\ContainerInterface
;
17 use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface
;
19 use Rapsys\AirBundle\Entity\Civility
;
20 use Rapsys\AirBundle\Entity\Group
;
21 use Rapsys\AirBundle\Entity\User
;
22 use Rapsys\AirBundle\Entity\Location
;
23 use Rapsys\AirBundle\Entity\Slot
;
28 class AirFixtures
extends Fixture
{
30 * Air fixtures constructor
32 public function __construct(protected ContainerInterface
$container, protected UserPasswordHasherInterface
$hasher) {
38 public function load(ObjectManager
$manager) {
48 foreach($civilityTree as $civilityData) {
49 $civility = new Civility($civilityData);
50 $manager->persist($civility);
51 $civilitys[$civilityData] = $civility;
55 //TODO: insert countries from https://raw.githubusercontent.com/raramuridesign/mysql-country-list/master/country-lists/mysql-country-list-detailed-info.sql
56 #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;
57 #insert into countries (code, alpha, title, created, updated) select countryCode, isoAlpha3, countryName, NOW(), NOW() FROM apps_countries_detailed ORDER BY countryCode ASC, isoAlpha3 ASC;
61 'Argentine Tango' => [
62 'Milonga', 'Class and milonga', 'Public class', 'Private class'
68 foreach($danceTree as $danceTitle => $danceData) {
69 foreach($danceData as $danceType) {
70 $dance = new Dance($danceTitle, $danceType);
71 $manager->persist($dance);
77 //XXX: ROLE_XXX is required by
88 foreach($groupTree as $groupData) {
89 $group = new Group($groupData);
90 $manager->persist($group);
91 $groups[$groupData] = $group;
95 //Flush to get the ids
103 'mail' => 'tango@rapsys.eu',
104 'pseudonym' => 'Milonga Raphaël',
105 'forename' => 'Raphaël',
106 'surname' => 'Gertz',
107 'phone' => '+33677952829',
113 'mail' => 'denis.courvoisier@wanadoo.fr',
114 'pseudonym' => 'DJ Sined',
115 'forename' => 'Denis',
116 'surname' => 'Courvoisier',
117 'phone' => '+33600000000',
123 'mail' => 'rannou402@orange.fr',
124 'pseudonym' => 'Trio Tango',
125 'forename' => 'Michel',
126 'surname' => 'Rannou',
127 'phone' => '+33600000000',
132 'group' => 'Regular',
133 'mail' => 'roxmaps@gmail.com',
134 'pseudonym' => 'Roxana',
135 'forename' => 'Roxana',
136 'surname' => 'Prado',
137 'phone' => '+33600000000',
144 foreach($userTree as $userData) {
145 $user = new User($userData['mail'], $userData['password'], $civilitys[$userData['short']], $userData['forename'], $userData['surname']);
146 #TODO: check that password is hashed correctly !!!
147 #$user->setPassword($this->hasher->hashPassword($user, $userData['password']));
148 $user->setPseudonym($userData['pseudonym']);
149 $user->setPhone($userData['phone']);
150 $user->addGroup($groups[$userData['group']]);
151 $manager->persist($user);
156 //Flush to get the ids
160 //XXX: adding a new zipcode here requires matching accuweather uris in Command/WeatherCommand.php
161 //TODO: add descriptions as well
164 'title' => 'Garnier opera',
165 'short' => 'Garnier',
166 'address' => '10 Place de l\'Opéra',
167 'zipcode' => '75009',
169 'latitude' => 48.871268,
170 'longitude' => 2.331832,
174 'title' => 'Tino-Rossi garden',
176 'address' => '2 Quai Saint-Bernard',
177 'zipcode' => '75005',
179 'latitude' => 48.847736,
180 'longitude' => 2.360953,
184 'title' => 'Trocadero esplanade',
185 'short' => 'Trocadero',
186 'address' => '1 Avenue Hussein 1er de Jordanie',
187 #75016 pour meteo-france, accuweather supporte 75116
188 'zipcode' => '75116',
190 'latitude' => 48.861888,
191 'longitude' => 2.288853,
195 'title' => 'Colette place',
196 'short' => 'Colette',
197 'address' => 'Galerie du Théâtre Français',
198 'zipcode' => '75001',
200 'latitude' => 48.863219,
201 'longitude' => 2.335847,
205 'title' => 'Swan island',
207 'address' => 'Allée des Cygnes',
208 'zipcode' => '75015',
210 'latitude' => 48.849976, #48.849976
211 'longitude' => 2.279603, #2.2796029,
215 'title' => 'Jussieu esplanade',
216 'short' => 'Jussieu',
217 'address' => '25 rue des Fossés Saint-Bernard',
218 'zipcode' => '75005',
220 'latitude' => 48.847955, #48.8479548
221 'longitude' => 2.353291, #2.3532907,
225 'title' => 'Orleans gallery',
226 'short' => 'Orleans',
227 'address' => '8 Galerie du Jardin',
228 'zipcode' => '75001',
230 'latitude' => 48.863885,
231 'longitude' => 2.337387,
235 'title' => 'Orsay museum',
237 'address' => '1 rue de la Légion d\'Honneur',
238 'zipcode' => '75007',
240 'latitude' => 48.860418,
241 'longitude' => 2.325815,
245 'title' => 'Saint-Honore market',
247 'address' => '1 Passage des Jacobins',
248 'zipcode' => '75001',
250 'latitude' => 48.866992,
251 'longitude' => 2.331752,
255 'title' => 'Igor Stravinsky place',
256 'short' => 'Stravinsky',
257 'address' => '2 rue Brisemiche',
258 'zipcode' => '75004',
260 'latitude' => 48.859244,
261 'longitude' => 2.351289,
265 'title' => 'Tokyo palace',
267 'address' => '14 Avenue de New York',
268 'zipcode' => '75116',
270 'latitude' => 48.863827,
271 'longitude' => 2.297339,
275 'title' => 'Drawings\' garden',
276 'short' => 'Villette',
277 'address' => 'Allée du Belvédère',
278 'zipcode' => '75019',
280 'latitude' => 48.892503,
281 'longitude' => 2.389300,
285 'title' => 'Louvre palace',
287 'address' => 'Quai François Mitterrand',
288 'zipcode' => '75001',
290 'latitude' => 48.860386,
291 'longitude' => 2.332611,
295 'title' => 'Monde garden',
297 'address' => '63 avenue Pierre Mendès-France',
298 'zipcode' => '75013',
300 'latitude' => 48.840451,
301 'longitude' => 2.367638,
308 foreach($locationTree as $locationData) {
309 $location = new Location();
310 $location->setTitle($locationData['title']);
311 $location->setShort($locationData['short']);
312 $location->setAddress($locationData['address']);
313 $location->setZipcode($locationData['zipcode']);
314 $location->setCity($locationData['city']);
315 $location->setLatitude($locationData['latitude']);
316 $location->setLongitude($locationData['longitude']);
317 $location->setHotspot($locationData['hotspot']);
318 $manager->persist($location);
319 $locations[$locationData['title']] = $location;
323 //Flush to get the ids
336 foreach($slotTree as $slotData) {
337 $slot = new Slot($slotData);
338 $manager->persist($slot);
339 $slots[$slot->getId()] = $slot;
343 //Flush to get the ids