Documents for not conserved
This commit is contained in:
parent
68854f875b
commit
b84d4589fe
@ -4,6 +4,7 @@ namespace App\Controller;
|
||||
|
||||
use App\Entity\NotConserved;
|
||||
use App\Entity\Bibliography;
|
||||
use App\Entity\Document;
|
||||
use App\Entity\Image;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
@ -17,6 +18,7 @@ class NotConservedController extends AbstractController
|
||||
{
|
||||
$repo = $em->getRepository(NotConserved::class);
|
||||
//$repoBib = $em->getRepository(Bibliography::class);
|
||||
$repoImg = $em->getRepository(Image::class);
|
||||
|
||||
$records = $repo->findBy([], ['id' => 'ASC']);
|
||||
|
||||
@ -27,6 +29,12 @@ class NotConservedController extends AbstractController
|
||||
$record->setLng($repo->coordinates($id)['lng']);
|
||||
//$biblio = $repoBib->findAllByNotConserved($id);
|
||||
//$record->setBibliographies($biblio);
|
||||
$images = $repoImg->findBy(
|
||||
['notConserved' => $record->getId()],
|
||||
['sequence' => 'ASC']
|
||||
);
|
||||
|
||||
$record->setImages($images);
|
||||
$records[$key] = $record;
|
||||
}
|
||||
|
||||
@ -45,8 +53,10 @@ class NotConservedController extends AbstractController
|
||||
$repo = $em->getRepository(Bibliography::class);
|
||||
|
||||
$biblio = $repo->findAllByNotConserved($notConserved->getId());
|
||||
|
||||
$repo = $em->getRepository(Document::class);
|
||||
$documents = $repo->findByNotConserved($notConserved->getId());
|
||||
$notConserved->setBibliographies($biblio);
|
||||
$notConserved->setDocuments($documents);
|
||||
|
||||
$notConserved->setLat($coordinates['lat']);
|
||||
$notConserved->setLng($coordinates['lng']);
|
||||
@ -58,8 +68,6 @@ class NotConservedController extends AbstractController
|
||||
|
||||
$notConserved->setImages($images);
|
||||
|
||||
return $this->json(
|
||||
$notConserved,
|
||||
);
|
||||
return $this->json($notConserved);
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,11 @@ class NotConserved implements \JsonSerializable
|
||||
*/
|
||||
private ?array $bibliographies = null;
|
||||
|
||||
/**
|
||||
* @var Document[] $documents
|
||||
*/
|
||||
private ?array $documents = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true, name: 'periodo')]
|
||||
private ?string $period = null;
|
||||
|
||||
@ -105,6 +110,18 @@ class NotConserved implements \JsonSerializable
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDocuments(): ?array
|
||||
{
|
||||
return $this->documents;
|
||||
}
|
||||
|
||||
public function setDocuments(array $documents): static
|
||||
{
|
||||
$this->documents = $documents;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPeriod(): ?string
|
||||
{
|
||||
return $this->period;
|
||||
@ -182,6 +199,7 @@ class NotConserved implements \JsonSerializable
|
||||
'shortDescription' => $this->shortDescription,
|
||||
'author' => $this->author,
|
||||
'bibliography' => $this->bibliographies,
|
||||
'documents' => $this->documents,
|
||||
'images' => $this->images,
|
||||
];
|
||||
}
|
||||
|
@ -46,6 +46,34 @@ class DocumentRepository extends ServiceEntityRepository
|
||||
return $query->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Document[] Returns an array of Document objects
|
||||
*/
|
||||
public function findByNotConserved(int $notConservedId): array
|
||||
{
|
||||
$rsm = new ResultSetMappingBuilder($this->getEntityManager());
|
||||
$rsm->addRootEntityFromClassMetadata('App\Entity\Document', 'd');
|
||||
$query = $this->getEntityManager()->createNativeQuery(
|
||||
'SELECT
|
||||
id,
|
||||
titolo,
|
||||
filename,
|
||||
descrizione,
|
||||
autori,
|
||||
luogo,
|
||||
tipo
|
||||
FROM documento d
|
||||
JOIN non_conserv_documento
|
||||
ON id_documento = d.id
|
||||
WHERE id_non_conserv = :id
|
||||
',
|
||||
$rsm
|
||||
);
|
||||
|
||||
$query->setParameter('id', $notConservedId);
|
||||
|
||||
return $query->getResult();
|
||||
}
|
||||
// /**
|
||||
// * @return Document[] Returns an array of Document objects
|
||||
// */
|
||||
|
Loading…
Reference in New Issue
Block a user