diff --git a/includes/derivatives.inc b/includes/derivatives.inc index fbf4b9e7..c66944b1 100644 --- a/includes/derivatives.inc +++ b/includes/derivatives.inc @@ -37,7 +37,7 @@ function islandora_do_derivatives(AbstractObject $object, array $options) { $options += array( 'force' => FALSE, ); - $hooks = islandora_invoke_hook_list(ISLANDORA_DERVIATIVE_CREATION_HOOK, $object->models, array()); + $hooks = islandora_invoke_hook_list(ISLANDORA_DERVIATIVE_CREATION_HOOK, $object->models, array($object)); uasort($hooks, 'drupal_sort_weight'); $results = array(); diff --git a/islandora.api.php b/islandora.api.php index 39c6e454..18e5643b 100644 --- a/islandora.api.php +++ b/islandora.api.php @@ -578,6 +578,8 @@ function hook_CMODEL_PID_islandora_overview_object_alter(AbstractObject &$object /* * Defines derivative functions to be executed based on certain conditions. * + * @param AbstractObject $object + * Object to which derivatives will be added * This hook fires when an object/datastream is ingested or a datastream is * modified. * @@ -611,33 +613,38 @@ function hook_CMODEL_PID_islandora_overview_object_alter(AbstractObject &$object * - file: A string denoting the path to the file where the function * is being called from. */ -function hook_islandora_derivative() { - return array( - array( - 'source_dsid' => 'OBJ', - 'destination_dsid' => 'DERIV', - 'weight' => '0', - 'function' => array( - 'islandora_derivatives_test_create_deriv_datastream', - ), +function hook_islandora_derivative(AbstractObject $object) { + + $derivatives[] = array( + 'source_dsid' => 'OBJ', + 'destination_dsid' => 'DERIV', + 'weight' => '0', + 'function' => array( + 'islandora_derivatives_test_create_deriv_datastream', ), - array( + ); + // Test object before adding this derivative. + if ($object['SOMEWEIRDDATASTREAM']->mimetype == "SOMETHING/ODD") { + $derivatives[] = array( 'source_dsid' => 'SOMEWEIRDDATASTREAM', 'destination_dsid' => 'STANLEY', 'weight' => '-1', 'function' => array( 'islandora_derivatives_test_create_some_weird_datastream', ), - ), - array( - 'source_dsid' => NULL, - 'destination_dsid' => 'NOSOURCE', - 'weight' => '-3', - 'function' => array( - 'islandora_derivatives_test_create_nosource_datastream', - ), + ); + } + + $derivatives[] = array( + 'source_dsid' => NULL, + 'destination_dsid' => 'NOSOURCE', + 'weight' => '-3', + 'function' => array( + 'islandora_derivatives_test_create_nosource_datastream', ), ); + + return $derivatives; } /**