function EntityEditWizardTest::getOperations

Retrieve a list of FormInterface classes by their step key in the wizard.

Parameters

mixed $cached_values: The values returned by $this->getTempstore()->get($this->getMachineName()); *.

Return value

array An associative array keyed on the step name with an array value with the following keys:

  • title (string): Human-readable title of the step.
  • form (string): Fully-qualified class name of the form for this step.
  • values (array): Optional array of cached values to override when on this step.
  • validate (array): Optional array of callables to be called when this step is validated.
  • submit (array): Optional array of callables to be called when this step is submitted.

Overrides FormWizardInterface::getOperations

File

tests/modules/ctools_wizard_test/src/Wizard/EntityEditWizardTest.php, line 43

Class

EntityEditWizardTest

Namespace

Drupal\ctools_wizard_test\Wizard

Code

public function getOperations($cached_values) {
  /** @var \Drupal\ctools_wizard_test\Entity\ExampleConfigEntity $page */
  $config_entity = $cached_values['ctools_wizard_test_config_entity'];
  $steps = [
    'general' => [
      'form' => 'Drupal\\ctools_wizard_test\\Form\\ExampleConfigEntityGeneralForm',
      'title' => $this->t('General'),
    ],
    'one' => [
      'form' => 'Drupal\\ctools_wizard_test\\Form\\ExampleConfigEntityOneForm',
      'title' => $this->t('Form One'),
    ],
    'two' => [
      'form' => 'Drupal\\ctools_wizard_test\\Form\\ExampleConfigEntityTwoForm',
      'title' => $this->t('Form Two'),
    ],
  ];
  // To test that we can get the config entity and add/remove steps
  // based on it's values, we'll add a special step only when the entity
  // is pre-existing.
  if (!empty($config_entity) && !$config_entity->isNew()) {
    $steps['existing'] = [
      'form' => 'Drupal\\ctools_wizard_test\\Form\\ExampleConfigEntityExistingForm',
      'title' => $this->t('Existing entity'),
    ];
  }
  return $steps;
}