Add Reuse endpoint

This commit is contained in:
Nicolò P 2025-08-08 11:13:13 +02:00
parent 660d409093
commit 875ca03568
3 changed files with 106 additions and 45 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

@ -0,0 +1,46 @@
<?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);
//$repoBib = $em->getRepository(Bibliography::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']);
//$biblio = $repoBib->findAllByNotConserved($id);
//$record->setBibliographies($biblio);
$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
],
);
}
}

View File

@ -37,6 +37,9 @@ 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: 'ordine', type: Types::SMALLINT)]
private ?int $sequence = null;
@ -139,6 +142,18 @@ class Image implements \JsonSerializable
return $this;
}
public function getReuse(): ?string
{
return $this->prehistoric;
}
public function setReuse(?string $reuse): static
{
$this->reuse = $reuse;
return $this;
}
public function getSequence(): ?int
{
return $this->sequence;