Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To support this a module need only declare what steps they wish to add and what functions those steps perform.

Adding Steps

To let islandora know what steps you are providing you must implement the islandora_ingest_steps hook(s):

...

Each step should consist of a unique name mapped to an array of properties which take different parameters based upon type:

Shared properties

  • type: The type of step. Either "form" or "callback".
  • module: A module from which we want to load an include file.
  • file: A file to include (relative to the module's path, including the file's extension).
  • weight: Steps are sorted by weight. The expected range between -50 to 50. The order is undefined for steps which have the same weight.

Form properties

  • form_id: The form building function to call to get the form structure for this step.
  • args: An array of arguments to pass to the form building function, These will be appended after $form, and $form_state.

Callback properties

  • do_function: An associate array including:
    • function: The callback function to be called.
    • args: An array of arguments to pass to the callback function.
  • undo_function: An associate array including:
    • function: The callback function to be called to reverse the executed action.
    • args: An array of arguments to pass to the callback function.

...


Code Block
function form_id_undo_submit(array $form, array &$form_state);


Example implementation


Code Block
/**
 * Implements hook_islandora_ingest_steps().
 */
function islandora_basic_image_islandora_sp_basic_image_islandora_ingest_steps() {
  return array(
    'islandora_basic_image' => array(
      'weight' => 10,
      'type' => 'form',
      'form_id' => 'islandora_basic_image_image_upload_form',
      'module' => 'islandora_basic_image',
      'file' => 'includes/image_upload.form.inc',
    ),
  );
}


Altering Steps

Sometimes you will want to conditionally include/remove steps based on other steps. You can do this via the alter hook(s):


Code Block
function hook_islandora_ingest_steps_alter(array &steps, array $form_state);

function hook_CMODEL_islandora_ingest_steps_alter(array &steps, array $form_state);


Example implementation


Code Block
/**
 * Implements hook_islandora_ingest_steps_alter().
 */
function islandora_marcxml_islandora_ingest_steps_alter(array &$steps, array &$form_state) {
  if (isset($steps['xml_form_builder_metadata_step'])) {
    $metadata_step_storage = islandora_ingest_form_get_step_storage($form_state, 'xml_form_builder_metadata_step');
    if (isset($metadata_step_storage['association']) && $metadata_step_storage['association']['dsid'] == 'MODS') {
      $steps['islandora_marcxml_upload'] = array(
        'type' => 'form',
        'weight' => 1,
        'form_id' => 'islandora_marcxml_file_form',
        'args' => array(),
        'file' => 'includes/file.form.inc',
        'module' => 'islandora_marcxml',
      );
    }
  }
}


Persisting information

As you seen in the previous step, there are some functions (islandora_ingest_form_get_step_storage) that help retrieve and persist information into the form storage. This allows our steps to share information with one another, as well as manipulate the list of prepared Fedora Objects.

...


Code Block
function &islandora_ingest_form_get_objects(array &$form_state);

function &islandora_ingest_form_get_object(array &$form_state);


Example implementation


Code Block
function xml_form_builder_islandora_ingest_steps(array &$form_state) {
  module_load_include('inc', 'xml_form_builder', 'includes/associations');
  $shared_storage = islandora_ingest_form_get_shared_storage($form_state);
  $metadata_step_storage = &islandora_ingest_form_get_step_storage($form_state, 'xml_form_builder_metadata_step');
  $association_step_storage = &islandora_ingest_form_get_step_storage($form_state, 'xml_form_builder_association_step');
  $association_step_storage['models'] = isset($association_step_storage['models']) ? $association_step_storage['models'] : $shared_storage['models'];
  $associations = xml_form_builder_get_associations(array(), $association_step_storage['models'], array());
  $metadata_step_storage['association'] = isset($metadata_step_storage['association']) ? $metadata_step_storage['association'] : current($associations);
  $num_associations = count($associations);
  $select_association_step = ($num_associations > 1) ? array(
    'weight' => 0,
    'type' => 'form',
    'form_id' => 'xml_form_builder_select_association_form',
    'module' => 'xml_form_builder',
    'file' => 'includes/select_association.form.inc',
    'args' => array($associations),
      ) : NULL;
  $metadata_step = ($num_associations >= 1) ? array(
    'weight' => 5,
    'type' => 'form',
    'form_id' => 'xml_form_builder_ingest_form',
    'module' => 'xml_form_builder',
    'file' => 'includes/ingest.form.inc',
    'args' => array($metadata_step_storage['association']),
      ) : NULL;
  return array(
    'xml_form_builder_association_step' => $select_association_step,
    'xml_form_builder_metadata_step' => $metadata_step,
  );
}