public function WorkflowNodeNextStateAction::execute in Workflow 8
Executes the plugin.
Overrides ExecutableInterface::execute
File
- src/
Plugin/ Action/ WorkflowNodeNextStateAction.php, line 45
Class
- WorkflowNodeNextStateAction
- Sets an entity to the next state.
Namespace
Drupal\workflow\Plugin\ActionCode
public function execute($object = NULL) {
if (!($transition = $this
->getTransitionForExecution($object))) {
$this
->messenger()
->addWarning('The object is not valid for this action.');
return;
}
/*
* Set the new next state.
*/
$entity = $transition
->getTargetEntity();
$field_name = $transition
->getFieldName();
$user = $transition
->getOwner();
// $comment = $transition->getComment();
$force = $this->configuration['force'];
// Get the node's new State Id (which is the next available state).
$to_sid = $transition
->getWorkflow()
->getNextSid($entity, $field_name, $user, $force);
// Add actual data.
$transition->to_sid = $to_sid;
// Fire the transition.
workflow_execute_transition($transition, $force);
}