public function FormsSteps::addStep in Forms Steps 8
Adds a step to the forms_steps.
Parameters
string $step_id: The step's ID.
string $label: The step's label.
string $entityType: The step's entity type.
string $entityBundle: The step's bundle.
string $formMode: The step's form_mode.
string $url: The step's URL.
Return value
\Drupal\forms_steps\FormsStepsInterface The forms_steps entity.
Overrides FormsStepsInterface::addStep
File
- src/
Entity/ FormsSteps.php, line 186
Class
- FormsSteps
- FormsSteps configuration entity to persistently store configuration.
Namespace
Drupal\forms_steps\EntityCode
public function addStep($step_id, $label, $entityType, $entityBundle, $formMode, $url) {
if (isset($this->Steps[$step_id])) {
throw new \InvalidArgumentException("The Step '{$step_id}' already exists in the forms steps '{$this->id()}'");
}
if (preg_match('/[^a-z0-9_]+/', $step_id)) {
throw new \InvalidArgumentException("The Step ID '{$step_id}' must contain only lowercase letters, numbers, and underscores");
}
$this->steps[$step_id] = [
'label' => $label,
'weight' => $this
->getNextWeight($this->steps),
'entity_type' => $entityType,
'entity_bundle' => $entityBundle,
'form_mode' => $formMode,
'url' => $url,
];
ksort($this->steps);
return $this;
}