public function StateItem::applyTransitionById in State Machine 8
Applies a transition with the given ID, changing the current state.
Parameters
string $transition_id: The transition ID.
Throws
\InvalidArgumentException Thrown when no matching transition was found.
Overrides StateItemInterface::applyTransitionById
File
- src/
Plugin/ Field/ FieldType/ StateItem.php, line 340
Class
- StateItem
- Plugin implementation of the 'state' field type.
Namespace
Drupal\state_machine\Plugin\Field\FieldTypeCode
public function applyTransitionById($transition_id) {
$transition = NULL;
if ($workflow = $this
->getWorkflow()) {
$transition = $workflow
->getTransition($transition_id);
}
if (!$transition) {
throw new \InvalidArgumentException(sprintf('Unknown transition ID "%s".', $transition_id));
}
$this
->applyTransition($transition);
}