You are here

public static function WorkflowTransition::create in Workflow 8

Parameters

array $values: $values[0] may contain a Workflow object or State object or State ID.

Return value

static The entity object.

Overrides EntityBase::create

9 calls to WorkflowTransition::create()
WorkflowDefaultWidget::formElement in src/Plugin/Field/FieldWidget/WorkflowDefaultWidget.php
Be careful: Widget may be shown in very different places. Test carefully!!
WorkflowManager::executeTransitionsOfEntity in src/Entity/WorkflowManager.php
Execute a single transition for the given entity.
WorkflowManager::getWorkflowTransitionForm in src/Entity/WorkflowManager.php
Gets the TransitionWidget in a form (for e.g., Workflow History Tab)
WorkflowScheduledTransition::save in src/Entity/WorkflowScheduledTransition.php
Saves a scheduled transition. If the transition is executed, save in history.
WorkflowState::deactivate in src/Entity/WorkflowState.php
Deactivate a Workflow State, moving existing content to a given State.

... See full list

File

src/Entity/WorkflowTransition.php, line 154

Class

WorkflowTransition
Implements an actual, executed, Transition.

Namespace

Drupal\workflow\Entity

Code

public static function create(array $values = []) {
  if (is_array($values) && isset($values[0])) {
    $value = $values[0];
    $state = NULL;
    if (is_string($value)) {
      $state = WorkflowState::load($value);
    }
    elseif (is_object($value) && $value instanceof WorkflowState) {
      $state = $value;
    }
    $values['wid'] = $state ? $state
      ->getWorkflowId() : '';
    $values['from_sid'] = $state ? $state
      ->id() : '';
  }

  // Add default values.
  $values += [
    'timestamp' => \Drupal::time()
      ->getRequestTime(),
    'uid' => \Drupal::currentUser()
      ->id(),
  ];
  return parent::create($values);
}