From 141d7f5941b479186da4584e1966825821882b91 Mon Sep 17 00:00:00 2001 From: Daniel Berthereau Date: Mon, 20 Nov 2023 00:00:00 +0000 Subject: [PATCH] Added argument "media_id" to search pages with a specific media. --- application/src/Api/Adapter/SitePageAdapter.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/application/src/Api/Adapter/SitePageAdapter.php b/application/src/Api/Adapter/SitePageAdapter.php index e18600db6..cfaebc40d 100644 --- a/application/src/Api/Adapter/SitePageAdapter.php +++ b/application/src/Api/Adapter/SitePageAdapter.php @@ -74,6 +74,17 @@ public function buildQuery(QueryBuilder $qb, array $query) ); } + if (isset($query['media_id']) && is_numeric($query['media_id'])) { + $blocksAlias = $this->createAlias(); + $qb->innerJoin('omeka_root.blocks', $blocksAlias); + $attachmentsAlias = $this->createAlias(); + $qb->innerJoin("$blocksAlias.attachments", $attachmentsAlias); + $qb->andWhere($qb->expr()->eq( + "$attachmentsAlias.media", + $this->createNamedParameter($qb, $query['media_id'])) + ); + } + if (isset($query['slug'])) { $qb->andWhere($qb->expr()->eq( 'omeka_root.slug',