Skip to content

Commit

Permalink
Added argument "media_id" to search pages with a specific media.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Berthereau authored and Daniel Berthereau committed Nov 20, 2023
1 parent 619c0af commit 141d7f5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions application/src/Api/Adapter/SitePageAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 141d7f5

Please sign in to comment.