Browse Source

made derivative creation object state aware

pull/405/head
Alan Stanley 11 years ago
parent
commit
cdcc594065
  1. 2
      includes/derivatives.inc
  2. 23
      islandora.api.php

2
includes/derivatives.inc

@ -37,7 +37,7 @@ function islandora_do_derivatives(AbstractObject $object, array $options) {
$options += array( $options += array(
'force' => FALSE, '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'); uasort($hooks, 'drupal_sort_weight');
$results = array(); $results = array();

23
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. * 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 * This hook fires when an object/datastream is ingested or a datastream is
* modified. * 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 * - file: A string denoting the path to the file where the function
* is being called from. * is being called from.
*/ */
function hook_islandora_derivative() { function hook_islandora_derivative(AbstractObject $object) {
return array(
array( $derivatives[] = array(
'source_dsid' => 'OBJ', 'source_dsid' => 'OBJ',
'destination_dsid' => 'DERIV', 'destination_dsid' => 'DERIV',
'weight' => '0', 'weight' => '0',
'function' => array( 'function' => array(
'islandora_derivatives_test_create_deriv_datastream', 'islandora_derivatives_test_create_deriv_datastream',
), ),
), );
array( // Test object before adding this derivative.
if ($object['SOMEWEIRDDATASTREAM']->mimetype == "SOMETHING/ODD") {
$derivatives[] = array(
'source_dsid' => 'SOMEWEIRDDATASTREAM', 'source_dsid' => 'SOMEWEIRDDATASTREAM',
'destination_dsid' => 'STANLEY', 'destination_dsid' => 'STANLEY',
'weight' => '-1', 'weight' => '-1',
'function' => array( 'function' => array(
'islandora_derivatives_test_create_some_weird_datastream', 'islandora_derivatives_test_create_some_weird_datastream',
), ),
), );
array( }
$derivatives[] = array(
'source_dsid' => NULL, 'source_dsid' => NULL,
'destination_dsid' => 'NOSOURCE', 'destination_dsid' => 'NOSOURCE',
'weight' => '-3', 'weight' => '-3',
'function' => array( 'function' => array(
'islandora_derivatives_test_create_nosource_datastream', 'islandora_derivatives_test_create_nosource_datastream',
), ),
),
); );
return $derivatives;
} }
/** /**

Loading…
Cancel
Save