Add image type + NotConserved

This commit is contained in:
2024-11-15 16:14:43 +01:00
parent b1c9fdbdf7
commit 54332fab42
9 changed files with 416 additions and 2 deletions

View File

@@ -0,0 +1,33 @@
<?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' => '*']
);
}
}

View File

@@ -26,7 +26,7 @@ class SiteController extends AbstractController
$images = new ArrayCollection(
$repo->findBy(
['site' => $site->getId()],
['sequence' => 'DESC']
['sequence' => 'ASC']
)
);
$site->setImages($images);
@@ -34,6 +34,9 @@ class SiteController extends AbstractController
$site->setLat((float) $coords['lat']);
$site->setLng((float) $coords['lng']);
return $this->json( $site );
return $this->json(
$site,
headers: ['Access-Control-Allow-Origin' => '*']
);
}
}