56 lines
1.5 KiB
PHP
56 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\DataFixtures;
|
|
|
|
use App\Entity\Signal;
|
|
use App\ValueObject\Point;
|
|
use DateInterval;
|
|
use DateTimeImmutable;
|
|
use DateTimeZone;
|
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
|
use Doctrine\Persistence\ObjectManager;
|
|
|
|
class SignalFixtures extends Fixture
|
|
{
|
|
public function load(ObjectManager $manager): void
|
|
{
|
|
$baseTime = new DateTimeImmutable('2024-08-01 12:00:00', new DateTimeZone('UTC'));
|
|
$coordinates = [
|
|
[
|
|
'user' => 'user-alpha',
|
|
'lat' => -11.6877,
|
|
'lng' => 27.5026,
|
|
'offset' => 0,
|
|
],
|
|
[
|
|
'user' => 'user-beta',
|
|
'lat' => -11.6895,
|
|
'lng' => 27.5081,
|
|
'offset' => 3,
|
|
],
|
|
[
|
|
'user' => 'user-alpha',
|
|
'lat' => -11.6852,
|
|
'lng' => 27.4974,
|
|
'offset' => 6,
|
|
],
|
|
];
|
|
|
|
foreach ($coordinates as $config) {
|
|
$signalLocation = Point::fromLatLng($config['lat'], $config['lng']);
|
|
|
|
$signal = new Signal()
|
|
->setUserKey($config['user'])
|
|
->setUserLocation(Point::fromLatLng($config['lat'], $config['lng']))
|
|
->setSignalLocation($signalLocation)
|
|
->setCreatedAt($baseTime->add(new DateInterval(sprintf('PT%dM', $config['offset']))));
|
|
|
|
$manager->persist($signal);
|
|
}
|
|
|
|
$manager->flush();
|
|
}
|
|
}
|