34 lines
1.0 KiB
PHP
34 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use App\Entity\NotConserved;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
use Symfony\Component\Routing\Attribute\Route;
|
|
|
|
class NotConservedController extends AbstractController
|
|
{
|
|
#[Route('/not_conserved', name: 'app_not_conserved')]
|
|
public function index(EntityManagerInterface $em): JsonResponse
|
|
{
|
|
$repo = $em->getRepository(NotConserved::class);
|
|
|
|
$records = $repo->findAll();
|
|
|
|
foreach ($records as $key => $record) {
|
|
$record->setLat($repo->coordinates($record->getId())['lat']);
|
|
$record->setLng($repo->coordinates($record->getId())['lng']);
|
|
$records[$key] = $record;
|
|
}
|
|
|
|
return $this->json([
|
|
'message' => 'All records for not conserved archaeological assets',
|
|
'records' => $records
|
|
],
|
|
headers: ['Access-Control-Allow-Origin' => '*']
|
|
);
|
|
}
|
|
}
|