Skip to content

Commit

Permalink
Merge pull request #2054 from Daniel-KM/feature/trigger_subjectvalues
Browse files Browse the repository at this point in the history
Added an event to get linked resources via subject values.
  • Loading branch information
zerocrates authored Jun 12, 2023
2 parents 499bfb1 + 7a1a566 commit 65f8525
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions application/src/Api/Adapter/AbstractResourceEntityAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use DateTime;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\QueryBuilder;
use Laminas\EventManager\Event;
use Omeka\Api\Representation\ValueRepresentation;
use Omeka\Api\Request;
use Omeka\Entity\EntityInterface;
Expand Down Expand Up @@ -550,6 +551,14 @@ public function getSubjectValues(Resource $resource, $page = null, $perPage = nu
->orderBy('property.id, resource_template_property.alternateLabel, resource.title')
->setMaxResults($perPage)
->setFirstResult($offset);
$event = new Event('api.subject_values.query', $this, [
'queryBuilder' => $qb,
'resource' => $resource,
'propertyId' => $propertyId,
'resourceType' => $resourceType,
'siteId' => $siteId,
]);
$this->getEventManager()->triggerEvent($event);
$results = $qb->getQuery()->getResult();
return $results;
}
Expand All @@ -573,6 +582,14 @@ public function getSubjectValuesSimple(Resource $resource, $propertyId = null, $
->join('value.property', 'property')
->join('property.vocabulary', 'vocabulary')
->select("CONCAT(vocabulary.prefix, ':', property.localName) term, IDENTITY(value.resource) id, resource.title title");
$event = new Event('api.subject_values_simple.query', $this, [
'queryBuilder' => $qb,
'resource' => $resource,
'propertyId' => $propertyId,
'resourceType' => $resourceType,
'siteId' => $siteId,
]);
$this->getEventManager()->triggerEvent($event);
return $qb->getQuery()->getResult();
}

Expand Down

0 comments on commit 65f8525

Please sign in to comment.