3 namespace Rapsys\AirBundle\DataFixtures
;
5 use Doctrine\Bundle\FixturesBundle\Fixture
;
6 use Doctrine\Persistence\ObjectManager
;
7 use Symfony\Component\DependencyInjection\ContainerInterface
;
8 use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface
;
10 use Rapsys\AirBundle\Entity\Civility
;
11 use Rapsys\AirBundle\Entity\Group
;
12 use Rapsys\AirBundle\Entity\User
;
13 use Rapsys\AirBundle\Entity\Location
;
14 use Rapsys\AirBundle\Entity\Slot
;
16 class AirFixtures
extends Fixture
{
18 * Air fixtures constructor
20 public function __construct(protected ContainerInterface
$container, protected UserPasswordHasherInterface
$hasher) {
26 public function load(ObjectManager
$manager) {
28 $civilityTree = array(
36 foreach($civilityTree as $civilityData) {
37 $civility = new Civility();
38 $civility->setTitle($civilityData);
39 $civility->setCreated(new \
DateTime('now'));
40 $civility->setUpdated(new \
DateTime('now'));
41 $manager->persist($civility);
42 $civilitys[$civilityData] = $civility;
46 //TODO: insert countries from https://raw.githubusercontent.com/raramuridesign/mysql-country-list/master/country-lists/mysql-country-list-detailed-info.sql
47 #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;
48 #insert into countries (code, alpha, title, created, updated) select countryCode, isoAlpha3, countryName, NOW(), NOW() FROM apps_countries_detailed ORDER BY countryCode ASC, isoAlpha3 ASC;
52 'Argentine Tango' => [
53 'Milonga', 'Class and milonga', 'Public class', 'Private class'
59 foreach($danceTree as $danceTitle => $danceData) {
60 foreach($danceData as $danceType) {
61 $dance = new Dance($danceTitle, $danceType);
62 $dance->setCreated(new \
DateTime('now'));
63 $dance->setUpdated(new \
DateTime('now'));
64 $manager->persist($dance);
70 //XXX: ROLE_XXX is required by
81 foreach($groupTree as $groupData) {
82 $group = new Group($groupData);
83 $group->setCreated(new \
DateTime('now'));
84 $group->setUpdated(new \
DateTime('now'));
85 $manager->persist($group);
86 $groups[$groupData] = $group;
90 //Flush to get the ids
98 'mail' => 'tango@rapsys.eu',
99 'pseudonym' => 'Milonga Raphaël',
100 'forename' => 'Raphaël',
101 'surname' => 'Gertz',
102 'phone' => '+33677952829',
108 'mail' => 'denis.courvoisier@wanadoo.fr',
109 'pseudonym' => 'DJ Sined',
110 'forename' => 'Denis',
111 'surname' => 'Courvoisier',
112 'phone' => '+33600000000',
118 'mail' => 'rannou402@orange.fr',
119 'pseudonym' => 'Trio Tango',
120 'forename' => 'Michel',
121 'surname' => 'Rannou',
122 'phone' => '+33600000000',
127 'group' => 'Regular',
128 'mail' => 'roxmaps@gmail.com',
129 'pseudonym' => 'Roxana',
130 'forename' => 'Roxana',
131 'surname' => 'Prado',
132 'phone' => '+33600000000',
139 foreach($userTree as $userData) {
140 $user = new User($userData['mail']);
141 $user->setPseudonym($userData['pseudonym']);
142 $user->setForename($userData['forename']);
143 $user->setSurname($userData['surname']);
144 $user->setPhone($userData['phone']);
145 $user->setPassword($this->hasher
->hashPassword($user, $userData['password']));
146 $user->setCivility($civilitys[$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
159 //XXX: adding a new zipcode here requires matching accuweather uris in Command/WeatherCommand.php
162 'title' => 'Garnier opera',
163 'short' => 'Garnier',
164 'address' => '10 Place de l\'Opéra',
165 'zipcode' => '75009',
167 'latitude' => 48.871268,
168 'longitude' => 2.331832,
172 'title' => 'Tino-Rossi garden',
174 'address' => '2 Quai Saint-Bernard',
175 'zipcode' => '75005',
177 'latitude' => 48.847736,
178 'longitude' => 2.360953,
182 'title' => 'Trocadero esplanade',
183 'short' => 'Trocadero',
184 'address' => '1 Avenue Hussein 1er de Jordanie',
185 #75016 pour meteo-france, accuweather supporte 75116
186 'zipcode' => '75116',
188 'latitude' => 48.861888,
189 'longitude' => 2.288853,
193 'title' => 'Colette place',
194 'short' => 'Colette',
195 'address' => 'Galerie du Théâtre Français',
196 'zipcode' => '75001',
198 'latitude' => 48.863219,
199 'longitude' => 2.335847,
203 'title' => 'Swan island',
205 'address' => 'Allée des Cygnes',
206 'zipcode' => '75015',
208 'latitude' => 48.849976, #48.849976
209 'longitude' => 2.279603, #2.2796029,
213 'title' => 'Jussieu esplanade',
214 'short' => 'Jussieu',
215 'address' => '25 rue des Fossés Saint-Bernard',
216 'zipcode' => '75005',
218 'latitude' => 48.847955, #48.8479548
219 'longitude' => 2.353291, #2.3532907,
223 'title' => 'Orleans gallery',
224 'short' => 'Orleans',
225 'address' => '8 Galerie du Jardin',
226 'zipcode' => '75001',
228 'latitude' => 48.863885,
229 'longitude' => 2.337387,
233 'title' => 'Orsay museum',
235 'address' => '1 rue de la Légion d\'Honneur',
236 'zipcode' => '75007',
238 'latitude' => 48.860418,
239 'longitude' => 2.325815,
243 'title' => 'Saint-Honore market',
245 'address' => '1 Passage des Jacobins',
246 'zipcode' => '75001',
248 'latitude' => 48.866992,
249 'longitude' => 2.331752,
253 'title' => 'Igor Stravinsky place',
254 'short' => 'Stravinsky',
255 'address' => '2 rue Brisemiche',
256 'zipcode' => '75004',
258 'latitude' => 48.859244,
259 'longitude' => 2.351289,
263 'title' => 'Tokyo palace',
265 'address' => '14 Avenue de New York',
266 'zipcode' => '75116',
268 'latitude' => 48.863827,
269 'longitude' => 2.297339,
273 'title' => 'Drawings\' garden',
274 'short' => 'Villette',
275 'address' => 'Allée du Belvédère',
276 'zipcode' => '75019',
278 'latitude' => 48.892503,
279 'longitude' => 2.389300,
283 'title' => 'Louvre palace',
285 'address' => 'Quai François Mitterrand',
286 'zipcode' => '75001',
288 'latitude' => 48.860386,
289 'longitude' => 2.332611,
293 'title' => 'Monde garden',
295 'address' => '63 avenue Pierre Mendès-France',
296 'zipcode' => '75013',
298 'latitude' => 48.840451,
299 'longitude' => 2.367638,
305 $locations = array();
306 foreach($locationTree as $locationData) {
307 $location = new Location();
308 $location->setTitle($locationData['title']);
309 $location->setShort($locationData['short']);
310 $location->setAddress($locationData['address']);
311 $location->setZipcode($locationData['zipcode']);
312 $location->setCity($locationData['city']);
313 $location->setLatitude($locationData['latitude']);
314 $location->setLongitude($locationData['longitude']);
315 $location->setHotspot($locationData['hotspot']);
316 $location->setCreated(new \
DateTime('now'));
317 $location->setUpdated(new \
DateTime('now'));
318 $manager->persist($location);
319 $locations[$locationData['title']] = $location;
323 //Flush to get the ids
336 foreach($slotTree as $slotData) {
338 $slot->setTitle($slotData);
339 $slot->setCreated(new \
DateTime('now'));
340 $slot->setUpdated(new \
DateTime('now'));
341 $manager->persist($slot);
342 $slots[$slot->getId()] = $slot;
346 //Flush to get the ids