Compare commits

..

8 Commits

11 changed files with 613 additions and 73 deletions

90
composer.lock generated
View File

@@ -347,16 +347,16 @@
},
{
"name": "doctrine/doctrine-bundle",
"version": "2.13.0",
"version": "2.13.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/DoctrineBundle.git",
"reference": "ca59d84b8e63143ce1aed90cdb333ba329d71563"
"reference": "2740ad8b8739b39ab37d409c972b092f632b025a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/ca59d84b8e63143ce1aed90cdb333ba329d71563",
"reference": "ca59d84b8e63143ce1aed90cdb333ba329d71563",
"url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/2740ad8b8739b39ab37d409c972b092f632b025a",
"reference": "2740ad8b8739b39ab37d409c972b092f632b025a",
"shasum": ""
},
"require": {
@@ -370,7 +370,7 @@
"symfony/console": "^5.4 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
"symfony/deprecation-contracts": "^2.1 || ^3",
"symfony/doctrine-bridge": "^5.4.19 || ^6.0.7 || ^7.0",
"symfony/doctrine-bridge": "^5.4.46 || ^6.4.3 || ^7.0.3",
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0",
"symfony/polyfill-php80": "^1.15",
"symfony/service-contracts": "^1.1.1 || ^2.0 || ^3"
@@ -447,7 +447,7 @@
],
"support": {
"issues": "https://github.com/doctrine/DoctrineBundle/issues",
"source": "https://github.com/doctrine/DoctrineBundle/tree/2.13.0"
"source": "https://github.com/doctrine/DoctrineBundle/tree/2.13.1"
},
"funding": [
{
@@ -463,7 +463,7 @@
"type": "tidelift"
}
],
"time": "2024-09-01T09:46:40+00:00"
"time": "2024-11-08T23:27:54+00:00"
},
{
"name": "doctrine/doctrine-migrations-bundle",
@@ -1746,16 +1746,16 @@
},
{
"name": "symfony/console",
"version": "v7.1.7",
"version": "v7.1.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "3284aafcac338b6e86fd955ee4d794cbe434151a"
"reference": "ff04e5b5ba043d2badfb308197b9e6b42883fcd5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/3284aafcac338b6e86fd955ee4d794cbe434151a",
"reference": "3284aafcac338b6e86fd955ee4d794cbe434151a",
"url": "https://api.github.com/repos/symfony/console/zipball/ff04e5b5ba043d2badfb308197b9e6b42883fcd5",
"reference": "ff04e5b5ba043d2badfb308197b9e6b42883fcd5",
"shasum": ""
},
"require": {
@@ -1819,7 +1819,7 @@
"terminal"
],
"support": {
"source": "https://github.com/symfony/console/tree/v7.1.7"
"source": "https://github.com/symfony/console/tree/v7.1.8"
},
"funding": [
{
@@ -1835,20 +1835,20 @@
"type": "tidelift"
}
],
"time": "2024-11-05T15:34:55+00:00"
"time": "2024-11-06T14:23:19+00:00"
},
{
"name": "symfony/dependency-injection",
"version": "v7.1.6",
"version": "v7.1.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/dependency-injection.git",
"reference": "1f12f9d580ef8dd09e3b756aa111cc2d5f311bfd"
"reference": "e4d13f0f394f4d02a041ff76acd31c5a20a5f70b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/1f12f9d580ef8dd09e3b756aa111cc2d5f311bfd",
"reference": "1f12f9d580ef8dd09e3b756aa111cc2d5f311bfd",
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/e4d13f0f394f4d02a041ff76acd31c5a20a5f70b",
"reference": "e4d13f0f394f4d02a041ff76acd31c5a20a5f70b",
"shasum": ""
},
"require": {
@@ -1899,7 +1899,7 @@
"description": "Allows you to standardize and centralize the way objects are constructed in your application",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/dependency-injection/tree/v7.1.6"
"source": "https://github.com/symfony/dependency-injection/tree/v7.1.8"
},
"funding": [
{
@@ -1915,7 +1915,7 @@
"type": "tidelift"
}
],
"time": "2024-10-25T15:11:02+00:00"
"time": "2024-11-09T09:16:45+00:00"
},
{
"name": "symfony/deprecation-contracts",
@@ -2745,16 +2745,16 @@
},
{
"name": "symfony/http-foundation",
"version": "v7.1.7",
"version": "v7.1.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
"reference": "5183b61657807099d98f3367bcccb850238b17a9"
"reference": "f4419ec69ccfc3f725a4de7c20e4e57626d10112"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/5183b61657807099d98f3367bcccb850238b17a9",
"reference": "5183b61657807099d98f3367bcccb850238b17a9",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/f4419ec69ccfc3f725a4de7c20e4e57626d10112",
"reference": "f4419ec69ccfc3f725a4de7c20e4e57626d10112",
"shasum": ""
},
"require": {
@@ -2764,12 +2764,12 @@
},
"conflict": {
"doctrine/dbal": "<3.6",
"symfony/cache": "<6.4"
"symfony/cache": "<6.4.12|>=7.0,<7.1.5"
},
"require-dev": {
"doctrine/dbal": "^3.6|^4",
"predis/predis": "^1.1|^2.0",
"symfony/cache": "^6.4|^7.0",
"symfony/cache": "^6.4.12|^7.1.5",
"symfony/dependency-injection": "^6.4|^7.0",
"symfony/expression-language": "^6.4|^7.0",
"symfony/http-kernel": "^6.4|^7.0",
@@ -2802,7 +2802,7 @@
"description": "Defines an object-oriented layer for the HTTP specification",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/http-foundation/tree/v7.1.7"
"source": "https://github.com/symfony/http-foundation/tree/v7.1.8"
},
"funding": [
{
@@ -2818,20 +2818,20 @@
"type": "tidelift"
}
],
"time": "2024-11-06T09:02:46+00:00"
"time": "2024-11-09T09:16:45+00:00"
},
{
"name": "symfony/http-kernel",
"version": "v7.1.7",
"version": "v7.1.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-kernel.git",
"reference": "7f137cda31fd41e422edcdc01915f2c095b84399"
"reference": "33fef24e3dc79d6d30bf4936531f2f4bd2ca189e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/7f137cda31fd41e422edcdc01915f2c095b84399",
"reference": "7f137cda31fd41e422edcdc01915f2c095b84399",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/33fef24e3dc79d6d30bf4936531f2f4bd2ca189e",
"reference": "33fef24e3dc79d6d30bf4936531f2f4bd2ca189e",
"shasum": ""
},
"require": {
@@ -2916,7 +2916,7 @@
"description": "Provides a structured process for converting a Request into a Response",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/http-kernel/tree/v7.1.7"
"source": "https://github.com/symfony/http-kernel/tree/v7.1.8"
},
"funding": [
{
@@ -2932,7 +2932,7 @@
"type": "tidelift"
}
],
"time": "2024-11-06T09:54:34+00:00"
"time": "2024-11-13T14:25:32+00:00"
},
{
"name": "symfony/polyfill-intl-grapheme",
@@ -3556,16 +3556,16 @@
},
{
"name": "symfony/string",
"version": "v7.1.6",
"version": "v7.1.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "61b72d66bf96c360a727ae6232df5ac83c71f626"
"reference": "591ebd41565f356fcd8b090fe64dbb5878f50281"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/61b72d66bf96c360a727ae6232df5ac83c71f626",
"reference": "61b72d66bf96c360a727ae6232df5ac83c71f626",
"url": "https://api.github.com/repos/symfony/string/zipball/591ebd41565f356fcd8b090fe64dbb5878f50281",
"reference": "591ebd41565f356fcd8b090fe64dbb5878f50281",
"shasum": ""
},
"require": {
@@ -3623,7 +3623,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v7.1.6"
"source": "https://github.com/symfony/string/tree/v7.1.8"
},
"funding": [
{
@@ -3639,20 +3639,20 @@
"type": "tidelift"
}
],
"time": "2024-09-25T14:20:29+00:00"
"time": "2024-11-13T13:31:21+00:00"
},
{
"name": "symfony/var-dumper",
"version": "v7.1.7",
"version": "v7.1.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
"reference": "f6ea51f669760cacd7464bf7eaa0be87b8072db1"
"reference": "7bb01a47b1b00428d32b5e7b4d3b2d1aa58d3db8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/f6ea51f669760cacd7464bf7eaa0be87b8072db1",
"reference": "f6ea51f669760cacd7464bf7eaa0be87b8072db1",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/7bb01a47b1b00428d32b5e7b4d3b2d1aa58d3db8",
"reference": "7bb01a47b1b00428d32b5e7b4d3b2d1aa58d3db8",
"shasum": ""
},
"require": {
@@ -3706,7 +3706,7 @@
"dump"
],
"support": {
"source": "https://github.com/symfony/var-dumper/tree/v7.1.7"
"source": "https://github.com/symfony/var-dumper/tree/v7.1.8"
},
"funding": [
{
@@ -3722,7 +3722,7 @@
"type": "tidelift"
}
],
"time": "2024-11-05T15:34:55+00:00"
"time": "2024-11-08T15:46:42+00:00"
},
{
"name": "symfony/var-exporter",

View File

@@ -16,6 +16,7 @@ class FindingController extends AbstractController
public function index(EntityManagerInterface $em): JsonResponse
{
$repo = $em->getRepository(Finding::class);
$imgRepo = $em->getRepository(Image::class);
$findings = $repo->findBy([], ['label' => 'ASC']);
@@ -23,6 +24,12 @@ class FindingController extends AbstractController
$coords = $repo->coordinates($finding->getId());
$finding->setLat($coords['lat']);
$finding->setLng($coords['lng']);
// TODO N + 1!!
$images = $imgRepo->findBy(
['finding' => $finding->getId()],
['sequence' => 'ASC']
);
$finding->setImages($images);
$findings[$key] = $finding;
}

View File

@@ -0,0 +1,66 @@
<?php
namespace App\Controller;
use App\Entity\Reuse;
use App\Entity\Bibliography;
use App\Entity\Image;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
class ReuseController extends AbstractController
{
#[Route('/reuse', name: 'app_reuse')]
public function index(EntityManagerInterface $em): JsonResponse
{
$repo = $em->getRepository(Reuse::class);
$repoImg = $em->getRepository(Image::class);
$records = $repo->findBy([], ['label' => 'ASC']);
// Terrible? N+1..
foreach ($records as $key => $record) {
$id = $record->getId();
$record->setLat($repo->coordinates($id)['lat']);
$record->setLng($repo->coordinates($id)['lng']);
$images = $repoImg->findBy(
['reuse' => $record->getId()],
['sequence' => 'ASC']
);
$record->setImages($images);
$records[$key] = $record;
}
return $this->json([
'message' => 'All records for reused assets',
'records' => $records
],
);
}
#[Route('/reuse/{id<\d+>}', name: 'app_reuse_record')]
public function record(Reuse $reuse, EntityManagerInterface $em): JsonResponse
{
$repo = $em->getRepository(Reuse::class);
$coordinates = $repo->coordinates($reuse->getId());
$repo = $em->getRepository(Bibliography::class);
$biblio = $repo->findAllByReuse($reuse->getId());
$reuse->setBibliography($biblio);
$reuse->setLat($coordinates['lat']);
$reuse->setLng($coordinates['lng']);
$repo = $em->getRepository(Image::class);
$images = $repo->findBy(
['reuse' => $reuse->getId()],
['sequence' => 'ASC']
);
$reuse->setImages($images);
return $this->json($reuse);
}
}

View File

@@ -2,6 +2,8 @@
namespace App\Controller;
use App\Entity\Document;
use App\Entity\Image;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
@@ -14,15 +16,48 @@ class UnderwaterController extends AbstractController
public function index(EntityManagerInterface $em): JsonResponse
{
$repo = $em->getRepository(Underwater::class);
$imgRepo = $em->getRepository(Image::class);
$underwater = $repo->findAll();
foreach ($underwater as $under) {
$coords = $repo->coordinates($under->getId());
$under->setLat($coords['lat']);
$under->setLng($coords['lng']);
/**
* @var Underwater $record
*/
foreach ($underwater as $key => $record) {
$coords = $repo->coordinates($record->getId());
$record->setLat($coords['lat']);
$record->setLng($coords['lng']);
// TODO N + 1!!
$images = $imgRepo->findBy(
['underwater' => $record->getId()],
['sequence' => 'ASC']
);
$record->setImages($images);
$underwater[$key] = $record;
}
return $this->json(['records' => $underwater]);
}
#[Route('/underwater/{id<\d+>}', name: 'app_underwater_record')]
public function record(Underwater $record, EntityManagerInterface $em)
{
$repo = $em->getRepository(Underwater::class);
$docRepo = $em->getRepository(Document::class);
$documents = $docRepo->findByUnderwater($record->getId());
$imgRepo = $em->getRepository(Image::class);
$images = $imgRepo->findBy(
['underwater' => $record->getId()],
['sequence' => 'ASC']
);
$coords = $repo->coordinates($record->getId());
$record->setLat($coords['lat']);
$record->setLng($coords['lng']);
$record->setImages($images);
$record->setDocuments($documents);
return $this->json($record);
}
}

View File

@@ -37,6 +37,12 @@ class Image implements \JsonSerializable
#[ORM\Column(name: 'affioramento', type: Types::BIGINT, nullable: true)]
private ?string $prehistoric = null;
#[ORM\Column(name: 'reimpiego', type: Types::BIGINT, nullable: true)]
private ?string $reuse = null;
#[ORM\Column(name: 'giacimento', type: Types::BIGINT, nullable: true)]
private ?string $underwater = null;
#[ORM\Column(name: 'ordine', type: Types::SMALLINT)]
private ?int $sequence = null;
@@ -139,6 +145,30 @@ class Image implements \JsonSerializable
return $this;
}
public function getReuse(): ?string
{
return $this->reuse;
}
public function setReuse(?string $reuse): static
{
$this->reuse = $reuse;
return $this;
}
public function getUnderwater(): ?string
{
return $this->underwater;
}
public function setUnderwater(?string $underwater): static
{
$this->underwater = $underwater;
return $this;
}
public function getSequence(): ?int
{
return $this->sequence;

277
src/Entity/Reuse.php Normal file
View File

@@ -0,0 +1,277 @@
<?php
namespace App\Entity;
use App\Repository\ReuseRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ReuseRepository::class)]
#[ORM\Table(name: 'reimpiego')]
class Reuse implements \JsonSerializable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 200, name: 'denominazione')]
private ?string $denomination = null;
#[ORM\Column(length: 200, nullable: true, name: 'materia')]
private ?string $material = null;
#[ORM\Column(length: 100, nullable: true, name: 'rinvenimento')]
private ?string $finding = null;
#[ORM\Column(length: 100, nullable: true, name: 'misure')]
private ?string $measurements = null;
#[ORM\Column(length: 200, nullable: true, name: 'datazione')]
private ?string $dating = null;
#[ORM\Column(length: 255, nullable: true, name: 'stato_conservazione')]
private ?string $conservationState = null;
#[ORM\Column(length: 255, nullable: true, name: 'luogo_conservazione')]
private ?string $conservationPlace = null;
#[ORM\Column(type: Types::TEXT, nullable: true, name: 'descrizione')]
private ?string $description = null;
#[ORM\Column(length: 255, nullable: true, name: 'autore_scheda')]
private ?string $author = null;
#[ORM\Column(name: 'comune', length: 10, nullable: false)]
private ?string $municipality = null;
#[ORM\Column(name: 'etichetta', length: 150, nullable: false)]
private ?string $label = null;
private ?float $lat = null;
private ?float $lng = null;
/**
* @var Bibliography[] $bibliography
*/
private ?array $bibliography = null;
/**
* @var Image[] $images
*/
private ?array $images = null;
public function getId(): ?int
{
return $this->id;
}
public function setId(string $id): static
{
$this->id = $id;
return $this;
}
public function getDenomination(): ?string
{
return $this->denomination;
}
public function setDenomination(string $denomination): static
{
$this->denomination = $denomination;
return $this;
}
public function getMaterial(): ?string
{
return $this->material;
}
public function setMaterial(?string $material): static
{
$this->material = $material;
return $this;
}
public function getFinding(): ?string
{
return $this->finding;
}
public function setFinding(?string $finding): static
{
$this->finding = $finding;
return $this;
}
public function getDating(): ?string
{
return $this->dating;
}
public function setDating(?string $dating): static
{
$this->dating = $dating;
return $this;
}
public function getConservationState(): ?string
{
return $this->conservationState;
}
public function setConservationState(?string $conservationState): static
{
$this->conservationState = $conservationState;
return $this;
}
public function getConservationPlace(): ?string
{
return $this->conservationPlace;
}
public function setConservationPlace(?string $conservationPlace): static
{
$this->conservationPlace = $conservationPlace;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): static
{
$this->description = $description;
return $this;
}
public function getAuthor(): ?string
{
return $this->author;
}
public function setAuthor(string $author): static
{
$this->author = $author;
return $this;
}
public function getMeasurements(): ?string
{
return $this->measurements;
}
public function setMeasurements(?string $measurements): static
{
$this->measurements = $measurements;
return $this;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(?string $label): static
{
$this->label = $label;
return $this;
}
public function getMunicipality(): ?string
{
return $this->municipality;
}
public function setMunicipality(?string $municipality): static
{
$this->municipality = $municipality;
return $this;
}
public function getLat(): ?float
{
return $this->lat;
}
public function setLat(float $lat): static
{
$this->lat = $lat;
return $this;
}
public function getLng(): ?float
{
return $this->lng;
}
public function setLng(float $lng): static
{
$this->lng = $lng;
return $this;
}
public function getBibliography(): ?array
{
return $this->bibliography;
}
public function setBibliography(array $bibliography): static
{
$this->bibliography = $bibliography;
return $this;
}
public function getImages(): ?array
{
return $this->images;
}
public function setImages(array $images): static
{
$this->images = $images;
return $this;
}
public function jsonSerialize(): array
{
return [
'id' => $this->id,
'denomination' => $this->denomination,
'material' => $this->material,
'measurements' => $this->measurements,
'finding' => $this->finding,
'dating' => $this->dating,
'conservationState' => $this->conservationState,
'conservationPlace' => $this->conservationPlace,
'description' => $this->description,
'author' => $this->author,
'label' => $this->label,
'municipality' => $this->municipality,
'coordinates' => [$this->lat, $this->lng],
'bibliography' => $this->bibliography,
'images' => $this->images,
];
}
}

View File

@@ -41,6 +41,16 @@ class Underwater implements JsonSerializable
private ?float $lng = null;
/**
* @var Image[] $images
*/
private ?array $images = null;
/**
* @var Document[] $documents
*/
private ?array $documents = null;
public function getId(): ?int
{
return $this->id;
@@ -161,6 +171,30 @@ class Underwater implements JsonSerializable
return $this;
}
public function getImages(): ?array
{
return $this->images;
}
public function setImages(?array $images): static
{
$this->images = $images;
return $this;
}
public function getDocuments(): ?array
{
return $this->documents;
}
public function setDocuments(?array $documents): static
{
$this->documents = $documents;
return $this;
}
public function jsonSerialize(): array
{
return [
@@ -173,6 +207,8 @@ class Underwater implements JsonSerializable
'shortDescription' => $this->shortDescription,
'author' => $this->author,
'label' => $this->label,
'images' => $this->images,
'documents' => $this->documents,
];
}
}

View File

@@ -120,6 +120,41 @@ class BibliographyRepository extends ServiceEntityRepository
$entities[] = $biblio;
}
return $entities;
}
/**
* @return Bibliography[]
*/
public function findAllByReuse(int $reuseId): array
{
$conn = $this->getEntityManager()->getConnection();
$sql = '
SELECT
b.id,
b.citazione,
b.riferimento,
br.pagine
FROM bibliografia b
INNER JOIN bibliografia_reimpiego br ON br.id_bibliografia = b.id
WHERE br.id_reimpiego = :reuseId
ORDER BY br.ordine ASC
';
$stmt = $conn->prepare($sql);
$results = $stmt->executeQuery(['reuseId' => $reuseId])->fetchAllAssociative();
$entities = [];
foreach ($results as $row) {
$biblio = new Bibliography();
$biblio->setId($row['id']);
$biblio->setCitation($row['citazione']);
$biblio->setReference($row['riferimento']);
$biblio->setPages($row['pagine']);
$entities[] = $biblio;
}
return $entities;
}
}

View File

@@ -100,6 +100,48 @@ class DocumentRepository extends ServiceEntityRepository
return $entities;
}
/**
* @return Document[] Returns an array of Document objects
*/
public function findByUnderwater(int $underwaterId): array
{
$conn = $this->getEntityManager()->getConnection();
$sql = '
SELECT
d.id,
d.titolo,
d.filename,
d.descrizione,
d.autori,
d.tipo,
d.luogo
FROM documento d
INNER JOIN giacimento_documento gd ON gd.id_documento = d.id
WHERE gd.id_giacimento = :underwaterId
ORDER BY d.titolo ASC
';
$stmt = $conn->prepare($sql);
$results = $stmt->executeQuery(['underwaterId' => $underwaterId])->fetchAllAssociative();
$entities = [];
foreach ($results as $row) {
$document = new Document();
$document->setId($row['id']);
$document->setTitle($row['titolo']);
$document->setFilename($row['filename']);
$document->setDescription($row['descrizione']);
$document->setConservationPlace($row['luogo']);
$document->setType($row['tipo']);
$document->setAuthors($row['autori']);
$entities[] = $document;
}
return $entities;
}
// /**
// * @return Document[] Returns an array of Document objects
// */

View File

@@ -32,28 +32,4 @@ class NotConservedRepository extends ServiceEntityRepository
return $conn->executeQuery($sql, ['id' => $id])
->fetchAssociative();
}
// /**
// * @return NotConserved[] Returns an array of NotConserved objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('n')
// ->andWhere('n.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('n.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?NotConserved
// {
// return $this->createQueryBuilder('n')
// ->andWhere('n.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@@ -0,0 +1,36 @@
<?php
namespace App\Repository;
use App\Entity\Reuse;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Finding>
*/
class ReuseRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Reuse::class);
}
public function coordinates(int $id)
{
$conn = $this->getEntityManager()->getConnection();
$sql = '
SELECT
ST_X(ST_AsText(coordinate)) as lng,
ST_Y(ST_AsText(coordinate)) as lat
FROM
reimpiego
WHERE id = :id
';
return $conn->executeQuery($sql, ['id' => $id])
->fetchAssociative();
}
}