From 8bb1b54beb434290972ff44b5b4ed51ac872899d Mon Sep 17 00:00:00 2001 From: John Flatness Date: Tue, 15 Sep 2020 15:03:57 -0400 Subject: [PATCH] Add "used" parameter for vocab members APIs (fix #1578, different implementation of the parameter part only of #1423) --- application/src/Api/Adapter/PropertyAdapter.php | 8 +++++++- application/src/Api/Adapter/ResourceClassAdapter.php | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/application/src/Api/Adapter/PropertyAdapter.php b/application/src/Api/Adapter/PropertyAdapter.php index fc512bc3f5..8d28eca331 100644 --- a/application/src/Api/Adapter/PropertyAdapter.php +++ b/application/src/Api/Adapter/PropertyAdapter.php @@ -115,7 +115,6 @@ public function buildQuery(QueryBuilder $qb, array $query) $this->createNamedParameter($qb, $query['vocabulary_prefix'])) ); } - if (isset($query['local_name'])) { $qb->andWhere($qb->expr()->eq( "omeka_root.localName", @@ -138,6 +137,13 @@ public function buildQuery(QueryBuilder $qb, array $query) $this->createNamedParameter($qb, $localName)) ); } + if (!empty($query['used'])) { + $valuesAlias = $this->createAlias(); + $qb->innerJoin( + 'omeka_root.values', + $valuesAlias, + ); + } } public function validateEntity(EntityInterface $entity, ErrorStore $errorStore) diff --git a/application/src/Api/Adapter/ResourceClassAdapter.php b/application/src/Api/Adapter/ResourceClassAdapter.php index 075b7c7b7b..08f9938c5e 100644 --- a/application/src/Api/Adapter/ResourceClassAdapter.php +++ b/application/src/Api/Adapter/ResourceClassAdapter.php @@ -128,6 +128,13 @@ public function buildQuery(QueryBuilder $qb, array $query) $this->createNamedParameter($qb, $localName)) ); } + if (!empty($query['used'])) { + $valuesAlias = $this->createAlias(); + $qb->innerJoin( + 'omeka_root.resources', + $valuesAlias, + ); + } } public function validateEntity(EntityInterface $entity, ErrorStore $errorStore)