Browse Source

update API to include DS modified params

pull/652/head
qadan 9 years ago
parent
commit
e63201f9f9
  1. 9
      includes/derivatives.inc
  2. 2
      includes/tuque_wrapper.inc
  3. 20
      islandora.api.php
  4. 3
      islandora.module

9
includes/derivatives.inc

@ -62,6 +62,9 @@ function islandora_run_derivatives(AbstractObject $object, $dsid) {
* from or NULL if it's the object itself. * from or NULL if it's the object itself.
* - destination_dsid: (Optional) String of the datastream id that is being * - destination_dsid: (Optional) String of the datastream id that is being
* created. To be used in the UI. * created. To be used in the UI.
* - ds_modified_params: (Optional, typically internally used) The array of
* parameters originally sent to FedoraDatastream::modifyDatastream(). Used
* to refine the derivative list; typically should't be passed in manually.
* *
* @return array * @return array
* An array of messages describing the outcome of the derivative events. * An array of messages describing the outcome of the derivative events.
@ -287,6 +290,7 @@ function islandora_remove_defer_derivatives_flag(AbstractObject $object) {
function islandora_get_derivative_list(AbstractObject $object, &$options) { function islandora_get_derivative_list(AbstractObject $object, &$options) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
$ds_modified_params = isset($options['ds_modified_params']) ? $options['ds_modified_params'] : array();
$options += array( $options += array(
'force' => FALSE, 'force' => FALSE,
); );
@ -294,11 +298,12 @@ function islandora_get_derivative_list(AbstractObject $object, &$options) {
$derivatives = islandora_invoke_hook_list( $derivatives = islandora_invoke_hook_list(
ISLANDORA_DERIVATIVE_CREATION_HOOK, ISLANDORA_DERIVATIVE_CREATION_HOOK,
$object->models, $object->models,
array($object) array($object),
$ds_modified_params
); );
foreach (islandora_build_hook_list(ISLANDORA_DERIVATIVE_CREATION_HOOK, $object->models) as $hook) { foreach (islandora_build_hook_list(ISLANDORA_DERIVATIVE_CREATION_HOOK, $object->models) as $hook) {
drupal_alter($hook, $derivatives, $object); drupal_alter($hook, $derivatives, $object, $ds_modified_params);
} }
uasort($derivatives, 'drupal_sort_weight'); uasort($derivatives, 'drupal_sort_weight');

2
includes/tuque_wrapper.inc

@ -594,7 +594,7 @@ class IslandoraFedoraDatastream extends FedoraDatastream {
protected function modifyDatastream(array $args) { protected function modifyDatastream(array $args) {
try { try {
parent::modifyDatastream($args); parent::modifyDatastream($args);
islandora_invoke_datastream_hooks(ISLANDORA_DATASTREAM_MODIFIED_HOOK, $this->parent->models, $this->id, $this->parent, $this); islandora_invoke_datastream_hooks(ISLANDORA_DATASTREAM_MODIFIED_HOOK, $this->parent->models, $this->id, $this->parent, $this, $args);
if ($this->state == 'D') { if ($this->state == 'D') {
islandora_invoke_datastream_hooks(ISLANDORA_DATASTREAM_PURGED_HOOK, $this->parent->models, $this->id, $this->parent, $this->id); islandora_invoke_datastream_hooks(ISLANDORA_DATASTREAM_PURGED_HOOK, $this->parent->models, $this->id, $this->parent, $this->id);
} }

20
islandora.api.php

@ -334,12 +334,12 @@ function hook_cmodel_pid_dsid_islandora_datastream_ingested(AbstractObject $obje
* @param AbstractObject $object * @param AbstractObject $object
* The object the datastream belongs to. * The object the datastream belongs to.
* @param AbstractDatastream $datastream * @param AbstractDatastream $datastream
* The datastream that was ingested. * The datastream that was modified.
* * @param array $params
* @todo We should also include what changes were made in a additional * The parameters from FedoraDatastream::modifyDatastream() used to modify the
* parameter. * datastream.
*/ */
function hook_islandora_datastream_modified(AbstractObject $object, AbstractDatastream $datastream) { function hook_islandora_datastream_modified(AbstractObject $object, AbstractDatastream $datastream, array $params) {
} }
@ -348,7 +348,7 @@ function hook_islandora_datastream_modified(AbstractObject $object, AbstractData
* *
* @see hook_islandora_datastream_modified() * @see hook_islandora_datastream_modified()
*/ */
function hook_cmodel_pid_islandora_datastream_modified(AbstractObject $object, AbstractDatastream $datastream) { function hook_cmodel_pid_islandora_datastream_modified(AbstractObject $object, AbstractDatastream $datastream, array $params) {
} }
@ -660,6 +660,10 @@ function hook_cmodel_pid_islandora_overview_object_alter(AbstractObject &$object
* *
* @param AbstractObject $object * @param AbstractObject $object
* Optional object to which derivatives will be added * Optional object to which derivatives will be added
* @param array $ds_modified_params
* An array that will contain the properties changed on the datastream if
* derivatives were triggered from a datastream_modified hook. Can be
* populated manually, but likely empty otherwise.
* *
* @return array * @return array
* An array containing an entry for each derivative to be created. Each entry * An array containing an entry for each derivative to be created. Each entry
@ -693,7 +697,7 @@ 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(AbstractObject $object = NULL) { function hook_islandora_derivative(AbstractObject $object = NULL, $ds_modified_params = array()) {
$derivatives[] = array( $derivatives[] = array(
'source_dsid' => 'OBJ', 'source_dsid' => 'OBJ',
'destination_dsid' => 'DERIV', 'destination_dsid' => 'DERIV',
@ -736,7 +740,7 @@ function hook_cmodel_pid_islandora_derivative() {
/** /**
* Allows for the altering of defined derivative functions. * Allows for the altering of defined derivative functions.
*/ */
function hook_islandora_derivative_alter(&$derivatives, AbstractObject $object) { function hook_islandora_derivative_alter(&$derivatives, AbstractObject $object, $ds_modified_params = array()) {
foreach ($derivatives as $key => $derivative) { foreach ($derivatives as $key => $derivative) {
if ($derivative['destination_dsid'] == 'TN') { if ($derivative['destination_dsid'] == 'TN') {
unset($derivatives[$key]); unset($derivatives[$key]);

3
islandora.module

@ -1798,11 +1798,12 @@ function islandora_islandora_datastream_ingested(AbstractObject $object, Abstrac
* equal to the current ingested datastream's id. Force is set to TRUE such that * equal to the current ingested datastream's id. Force is set to TRUE such that
* existing derivatives will be updated to reflect the change in the source. * existing derivatives will be updated to reflect the change in the source.
*/ */
function islandora_islandora_datastream_modified(AbstractObject $object, AbstractDatastream $datastream) { function islandora_islandora_datastream_modified(AbstractObject $object, AbstractDatastream $datastream, $params) {
module_load_include('inc', 'islandora', 'includes/derivatives'); module_load_include('inc', 'islandora', 'includes/derivatives');
$logging_results = islandora_do_derivatives($object, array( $logging_results = islandora_do_derivatives($object, array(
'source_dsid' => $datastream->id, 'source_dsid' => $datastream->id,
'force' => TRUE, 'force' => TRUE,
'ds_modified_params' => $params,
)); ));
islandora_derivative_logging($logging_results); islandora_derivative_logging($logging_results);
islandora_conditionally_clear_cache(); islandora_conditionally_clear_cache();

Loading…
Cancel
Save