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. 15
      islandora.api.php
  3. 4
      islandora.module

2
includes/orphaned_objects.inc

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

15
islandora.api.php

@ -970,11 +970,19 @@ function hook_islandora_datastream_filename_alter(&$filename, AbstractDatastream
/** /**
* Allow solution packs to register relationships used for children. * 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 * @return array
* - prefix (array): This is is a valid snip-it of SPARQL to register prefixes used in the predicates array. * - prefix (array): This is is a valid snip-it of SPARQL to register
* - predicate (array): This array contains predicates used by the solution pack for child objects. * 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() { function hook_islandora_solution_pack_child_relationships($cmodels) {
if ($cmodels === 'all' or in_array('my:cmodel_pid', $cmodels)) {
return array( return array(
'prefix' => array('PREFIX islandora: <http://islandora.ca/ontology/relsext#>'), 'prefix' => array('PREFIX islandora: <http://islandora.ca/ontology/relsext#>'),
'predicate' => array( 'predicate' => array(
@ -984,3 +992,4 @@ function hook_islandora_solution_pack_child_relationships() {
), ),
); );
} }
}

4
islandora.module

@ -2219,6 +2219,8 @@ function islandora_islandora_breadcrumbs_backends() {
/** /**
* Implements hook_islandora_solution_pack_child_relationships * 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()); return array('predicate' => array(), 'prefix' => array());
} }
Loading…
Cancel
Save