Browse Source

Add way to filter hook on content model.

pull/710/head
Jonathan Green 7 years ago
parent
commit
163fd9d273
No known key found for this signature in database
GPG Key ID: E96938FA4DF26243
  1. 2
      includes/orphaned_objects.inc
  2. 33
      islandora.api.php
  3. 4
      islandora.module

2
includes/orphaned_objects.inc

@ -169,7 +169,7 @@ WHERE {
FILTER (!bound(?liveparent))
} ORDER BY ?object
EOQ;
$parent_relationships = module_invoke_all('islandora_solution_pack_child_relationships');
$parent_relationships = module_invoke_all('islandora_solution_pack_child_relationships', 'all');
if (count($parent_relationships['predicate']) == 0) {
// No predicates to search for. Exit early.
return array();

33
islandora.api.php

@ -970,17 +970,26 @@ function hook_islandora_datastream_filename_alter(&$filename, AbstractDatastream
/**
* Allow solution packs to register relationships used for children.
*
* @param string|array $cmodels
* This takes either:
* - string: the string 'all'. Function returns all child relationships.
* - array: an array of cmodel PIDs to return the relationships for.
*
* @return array
* - prefix (array): This is is a valid snip-it of SPARQL to register prefixes used in the predicates array.
* - predicate (array): This array contains predicates used by the solution pack for child objects.
*/
function hook_islandora_solution_pack_child_relationships() {
return array(
'prefix' => array('PREFIX islandora: <http://islandora.ca/ontology/relsext#>'),
'predicate' => array(
'<fedora-rels-ext:isMemberOfCollection>',
'<fedora-rels-ext:isMemberOf>',
'<islandora:isPageOf>',
),
);
* - prefix (array): This is is a valid snip-it of SPARQL to register
* prefixes used in the predicates array.
* - predicate (array): This array contains predicates used by the solution
* pack for child objects.
*/
function hook_islandora_solution_pack_child_relationships($cmodels) {
if ($cmodels === 'all' or in_array('my:cmodel_pid', $cmodels)) {
return array(
'prefix' => array('PREFIX islandora: <http://islandora.ca/ontology/relsext#>'),
'predicate' => array(
'<fedora-rels-ext:isMemberOfCollection>',
'<fedora-rels-ext:isMemberOf>',
'<islandora:isPageOf>',
),
);
}
}

4
islandora.module

@ -2219,6 +2219,8 @@ function islandora_islandora_breadcrumbs_backends() {
/**
* Implements hook_islandora_solution_pack_child_relationships
*/
function islandora_islandora_solution_pack_child_relationships() {
function islandora_islandora_solution_pack_child_relationships($cmodels) {
// Return empty arrays from core implementation so that these keys always
// exist when the hook is called, even if no module responds.
return array('predicate' => array(), 'prefix' => array());
}
Loading…
Cancel
Save