Add Document and Bibliography
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Repository;
|
||||
use App\Entity\Document;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Document>
|
||||
@@ -16,6 +17,34 @@ class DocumentRepository extends ServiceEntityRepository
|
||||
parent::__construct($registry, Document::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Document[] Returns an array of Document objects
|
||||
*/
|
||||
public function findBySite(int $siteId): array
|
||||
{
|
||||
$rsm = new ResultSetMappingBuilder($this->getEntityManager());
|
||||
$rsm->addRootEntityFromClassMetadata('App\Entity\Document', 'd');
|
||||
$query = $this->getEntityManager()->createNativeQuery(
|
||||
'SELECT
|
||||
id,
|
||||
titolo,
|
||||
filename,
|
||||
descrizione,
|
||||
autori,
|
||||
tipo
|
||||
FROM documento d
|
||||
JOIN sito_documento
|
||||
ON id_documento = d.id
|
||||
WHERE id_sito = :id
|
||||
',
|
||||
$rsm
|
||||
);
|
||||
|
||||
$query->setParameter('id', $siteId);
|
||||
|
||||
return $query->getResult();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Document[] Returns an array of Document objects
|
||||
// */
|
||||
|
||||
Reference in New Issue
Block a user