Add Symfony payload mapping, fixtures, and QA tooling
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\DataFixtures;
|
||||
|
||||
use App\Entity\Signal;
|
||||
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) {
|
||||
$signal = new Signal()
|
||||
->setUserKey($config['user'])
|
||||
->setLat($config['lat'])
|
||||
->setLng($config['lng'])
|
||||
->setCreatedAt($baseTime->add(new DateInterval(sprintf('PT%dM', $config['offset']))));
|
||||
|
||||
$manager->persist($signal);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user