Skip to content

Developing a Workflow

Dickson Law edited this page Mar 16, 2018 · 4 revisions

Developing a Workflow

You can add your own wizard workflows for Batch Uploader by developing a plugin. Create a new class in your plugin's libraries/<your_plugin_name> directory inheriting from BatchUpload_Application_AbstractWizard.

Example:

class SampleWizards_DemoWorkflow extends BatchUpload_Application_AbstractWizard
{
    //...
}

Registering Your Workflow

Override the following fields in your workflow class:

  • job_type: The machine-readable slug for this job type. Must consist of lowercase alphanumerics or underscore characters only.
  • job_type_description: The human-readable description for this job type.

In your main plugin class:

class SampleWizardsPlugin extends Omeka_Plugin_AbstractPlugin:
{
    protected $_hooks = array(
        'initialize',
    );
    
    protected $_filters = array(
        'batch_upload_register_job_type',
    );

    protected $_wizards = array(
        'demo_workflow',
    );
    
    public function hookInitialize()
    {
        foreach ($this->_wizards as $supported_job_type)
        {
            $klass = "SampleWizards_" . Inflector::camelize($supported_job_type);
            $wizard = new $klass();
            $args = $wizard->integrate();
        }
    }
    
    public function filterBatchUploadRegisterJobType($args)
    {
    	foreach ($this->_wizards as $supported_job_type)
        {
            $klass = "SampleWizards_" . Inflector::camelize($supported_job_type);
            $wizard = new $klass();
            $args = $wizard->addType($args);
        }
        return $args;
    }
}

Steps

Implement the following methods for each step of your wizard workflow. For hook argument values, see Hooks and Filters.

  • step<n>Form($args): Add code for setting up the view for step n here. $args is an associative array with keys as shown in the batch_upload_<job_slug>_step_form hook. If left unimplemented, the wizard will simply render the step's view.
  • step<n>Process($args): Add code for processing a form submission from step n here. $args is an associative array with keys as shown in the batch_upload_<job_slug>_step_form hook. If left unimplemented, the wizard will automatically move to the next step.
  • step<n>Ajax($args): Add code for receiving Ajax requests from the view for step n here. This can be used for implementing asynchronous utilities for step views that include server-side validations or operations (e.g. inserting records). $args is an associative array with keys as shown in the batch_upload_<job_slug>_step_ajax hook. If left unimplemented, the wizard will simply not respond to Ajax requests made while on that step.

Views

Each step for your workflow should have an associated partial view. They should be stored in your plugin under paths of this form:

views/shared/batch_upload_forms/<job_type_slug>/<step number>.php

These views may receive partial variables from the "form" hook's partial_assigns data container.

Rewriting Job Rows

You can change how jobs of your custom workflow type appears on the Jobs Listings page by overriding the jobRow($row) method. $row is an associative array with keys as shown in the batch_upload_<job_slug>_job_row filter. You must return the modified row at the end of your overridden method.

Note: If you wish to retain the default progress or target description in your workflow type, remember to call $row = parent::jobRow($row);.