You are here

public function MigrateUIWizard::addStep in Migrate 7.2

Add a step to the wizard, using a step name and method.

Parameters

string $name: Translatable name for the step, to be used in the page title.

callable $form_method: Callable returning the form array for the step. This can be either the name of a MigrateUIWizard method, or a callable array specifying a method on a wizard extender. The validation method is formed from the method's name with the suffix 'Validate' added.

MigrateUIStep $after: Optional step after which to insert the new step. If omitted, add it at the end.

mixed $context: Optional data to be used by this step's form.

Return value

MigrateUIStep

File

migrate_ui/migrate_ui.wizard.inc, line 277
Migration wizard framework.

Class

MigrateUIWizard
The base class for migration wizards. Extend this class to implement a wizard UI for importing into Drupal from a given source format (Drupal, WordPress, etc.).

Code

public function addStep($name, $form_method, MigrateUIStep $after = NULL, $context = NULL) {
  if (!is_array($form_method)) {
    $form_method = array(
      $this,
      $form_method,
    );
  }
  $new_step = new MigrateUIStep($name, $form_method, $context);

  // There were no steps, so this is the only one.
  if (is_null($this->firstStep)) {
    $this->firstStep = $this->lastStep = $this->currentStep = $new_step;
  }
  else {

    // If no insertion point is specified, append to the end.
    if (is_null($after)) {
      $after = $this->lastStep;
    }

    // Do the insert, rewriting the links appropriately.
    $new_step->nextStep = $after->nextStep;
    if (is_null($new_step->nextStep)) {
      $this->lastStep = $new_step;
    }
    else {
      $new_step->nextStep->previousStep = $new_step;
    }
    $new_step->previousStep = $after;
    $after->nextStep = $new_step;
  }
  return $new_step;
}