Versions Compared

Key

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

...

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

 

Code Block
function hook_islandora_ingest_steps(array $form_state);

function hook_CMODEL_islandora_ingest_steps(array $form_state);
 

Which can be implemented by modules to conditionally add new steps. These functions are expected to return an associative array containing the appropriate steps to apply given the current $form_state:

...

Forms do not need to describe their undo. It's assumed to take the form of:

 

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.

There are two levels of storage: per step storage and shared storage. Shared storage is first populated with the configuration that was passed to islandora_ingest_form. Step storage will often contain custom data related to that particular step, and any submitted values for form steps:

...

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

function &islandora_ingest_form_get_step_storage(array &$form_state, $step_id = NULL);
 

And two functions for grabbing the prepared objects, one for grabbing all the objects, and one for grabbing the current object:

 

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,
  );
}