public function Workflow::getNextSid in Workflow 8
Returns the next state for the current state.
@usage Is used in VBO Bulk actions.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity at hand.
string $field_name:
\Drupal\Core\Session\AccountInterface $user:
bool $force:
Return value
string A State ID.
Overrides WorkflowInterface::getNextSid
File
- src/
Entity/ Workflow.php, line 323
Class
- Workflow
- Workflow configuration entity to persistently store configuration.
Namespace
Drupal\workflow\EntityCode
public function getNextSid(EntityInterface $entity, $field_name, AccountInterface $user, $force = FALSE) {
$current_sid = WorkflowManager::getCurrentStateId($entity, $field_name);
/** @var \Drupal\workflow\Entity\WorkflowState $current_state */
$current_state = WorkflowState::load($current_sid);
$options = $current_state
->getOptions($entity, $field_name, $user, $force);
// Loop over every option. To find the next one.
$flag = $current_state
->isCreationState();
$new_sid = $current_state
->id();
foreach ($options as $sid => $name) {
if ($flag) {
$new_sid = $sid;
break;
}
if ($sid == $current_state
->id()) {
$flag = TRUE;
}
}
return $new_sid;
}