From b446c66fd61401fced4c3d5d07a214b9f575418d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P?= Date: Thu, 10 Jul 2025 16:05:15 +0200 Subject: [PATCH] Add Reuse (WIP) --- src/Entity/Reuse.php | 277 +++++++++++++++++++++++++++++ src/Repository/ReuseRepository.php | 59 ++++++ 2 files changed, 336 insertions(+) create mode 100644 src/Entity/Reuse.php create mode 100644 src/Repository/ReuseRepository.php diff --git a/src/Entity/Reuse.php b/src/Entity/Reuse.php new file mode 100644 index 0000000..18ac2f0 --- /dev/null +++ b/src/Entity/Reuse.php @@ -0,0 +1,277 @@ +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, + ]; + } +} diff --git a/src/Repository/ReuseRepository.php b/src/Repository/ReuseRepository.php new file mode 100644 index 0000000..3952659 --- /dev/null +++ b/src/Repository/ReuseRepository.php @@ -0,0 +1,59 @@ + + */ +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 + rinvenimento + WHERE id = :id + '; + + return $conn->executeQuery($sql, ['id' => $id]) + ->fetchAssociative(); + } + // /** + // * @return Finding[] Returns an array of Finding objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('f') + // ->andWhere('f.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('f.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Finding + // { + // return $this->createQueryBuilder('f') + // ->andWhere('f.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +}