You are here

class WorkflowTransition in Workflow 8

Implements an actual, executed, Transition.

If a transition is executed, the new state is saved in the Field. If a transition is saved, it is saved in table {workflow_transition_history}.

Plugin annotation


@ContentEntityType(
  id = "workflow_transition",
  label = @Translation("Workflow transition"),
  label_singular = @Translation("Workflow transition"),
  label_plural = @Translation("Workflow transitions"),
  label_count = @PluralTranslation(
    singular = "@count Workflow transition",
    plural = "@count Workflow transitions",
  ),
  bundle_label = @Translation("Workflow type"),
  module = "workflow",
  translatable = FALSE,
  handlers = {
    "access" = "Drupal\workflow\WorkflowAccessControlHandler",
    "list_builder" = "Drupal\workflow\WorkflowTransitionListBuilder",
    "form" = {
       "add" = "Drupal\workflow\Form\WorkflowTransitionForm",
       "delete" = "Drupal\Core\Entity\EntityDeleteForm",
       "edit" = "Drupal\workflow\Form\WorkflowTransitionForm",
       "revert" = "Drupal\workflow\Form\WorkflowTransitionRevertForm",
     },
    "views_data" = "Drupal\workflow\WorkflowTransitionViewsData",
  },
  base_table = "workflow_transition_history",
  entity_keys = {
    "id" = "hid",
    "bundle" = "wid",
    "langcode" = "langcode",
  },
  permission_granularity = "bundle",
  bundle_entity_type = "workflow_type",
  field_ui_base_route = "entity.workflow_type.edit_form",
  links = {
    "canonical" = "/workflow_transition/{workflow_transition}",
    "delete-form" = "/workflow_transition/{workflow_transition}/delete",
    "edit-form" = "/workflow_transition/{workflow_transition}/edit",
    "revert-form" = "/workflow_transition/{workflow_transition}/revert",
  },
)

Hierarchy

Expanded class hierarchy of WorkflowTransition

7 files declare their use of WorkflowTransition
workflow.module in ./workflow.module
Support workflows made up of arbitrary states.
WorkflowDefaultWidget.php in src/Plugin/Field/FieldWidget/WorkflowDefaultWidget.php
WorkflowStateActionBase.php in src/Plugin/Action/WorkflowStateActionBase.php
WorkflowStateHistoryFormatter.php in src/Plugin/Field/FieldFormatter/WorkflowStateHistoryFormatter.php
WorkflowTransitionListBuilder.php in src/WorkflowTransitionListBuilder.php

... See full list

File

src/Entity/WorkflowTransition.php, line 63

Namespace

Drupal\workflow\Entity
View source
class WorkflowTransition extends ContentEntityBase implements WorkflowTransitionInterface {

  /*
   * Adds the messenger trait.
   */
  use MessengerTrait;

  /*
   * Adds the translation trait.
   */
  use StringTranslationTrait;

  /*
   * Adds variables and get/set methods for Workflow property.
   */
  use WorkflowTypeAttributeTrait;

  /*
   * Transition data: are provided via baseFieldDefinitions().
   */

  /*
   * Cache data.
   */

  /**
   * @var \Drupal\Core\Entity\EntityInterface
   *
   * @usage Use WorkflowTransition->getTargetEntity() to fetch this.
   */
  protected $entity = NULL;

  /**
   * @var \Drupal\user\UserInterface
   *
   * @usage Use WorkflowTransition->getOwner() to fetch this.
   */
  protected $user = NULL;

  /**
   * Extra data: describe the state of the transition.
   *
   * @var bool
   */
  protected $isScheduled = FALSE;

  /**
   * Extra data: describe the state of the transition.
   *
   * @var bool
   */
  protected $isExecuted = FALSE;

  /**
   * Extra data: describe the state of the transition.
   *
   * @var bool
   */
  protected $isForced = FALSE;

  /**
   * Entity class functions.
   */

  /**
   * Creates a new entity.
   *
   * @param array $values
   * @param string $entityType
   *   The entity type of this Entity subclass.
   * @param bool $bundle
   * @param array $translations
   *
   * @see entity_create()
   *
   * No arguments passed, when loading from DB.
   * All arguments must be passed, when creating an object programmatically.
   * One argument $entity may be passed, only to directly call delete() afterwards.
   */
  public function __construct(array $values = [], $entityType = 'workflow_transition', $bundle = FALSE, array $translations = []) {

    // Please be aware that $entity_type and $entityType are different things!
    parent::__construct($values, $entityType, $bundle, $translations);

    // This transition is not scheduled.
    $this->isScheduled = FALSE;

    // This transition is not executed, if it has no hid, yet, upon load.
    $this->isExecuted = $this
      ->id() > 0;
  }

  /**
   * {@inheritdoc}
   *
   * @param array $values
   *   $values[0] may contain a Workflow object or State object or State ID.
   *
   * @return static
   *   The entity object.
   */
  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);
  }

  /**
   * {@inheritdoc}
   */
  public function setValues($to_sid, $uid = NULL, $timestamp = NULL, $comment = '', $force_create = FALSE) {

    // Normally, the values are passed in an array, and set in parent::__construct, but we do it ourselves.
    $uid = $uid === NULL ? workflow_current_user()
      ->id() : $uid;
    $from_sid = $this
      ->getFromSid();
    $this
      ->set('to_sid', $to_sid);
    $this
      ->setOwnerId($uid);
    $this
      ->setTimestamp($timestamp == NULL ? \Drupal::time()
      ->getRequestTime() : $timestamp);
    $this
      ->setComment($comment);

    // If constructor is called with new() and arguments.
    if (!$from_sid && !$to_sid && !$this
      ->getTargetEntity()) {

      // If constructor is called without arguments, e.g., loading from db.
    }
    elseif ($from_sid && $this
      ->getTargetEntity()) {

      // Caveat: upon entity_delete, $to_sid is '0'.
      // If constructor is called with new() and arguments.
    }
    elseif (!$from_sid) {

      // Not all parameters are passed programmatically.
      if (!$force_create) {
        $this
          ->messenger()
          ->addError($this
          ->t('Wrong call to constructor Workflow*Transition(%from_sid to %to_sid)', [
          '%from_sid' => $from_sid,
          '%to_sid' => $to_sid,
        ]));
      }
    }
    return $this;
  }

  /**
   * CRUD functions.
   */

  /**
   * Saves the entity.
   *
   * Mostly, you'd better use WorkflowTransitionInterface::execute().
   *
   * {@inheritdoc}
   */
  public function save() {

    // Set Target Entity, to be used by Rules.

    /** @var \Drupal\workflow\Entity\WorkflowTransitionInterface $reference */
    $reference = $this
      ->get('entity_id')
      ->first();
    if ($reference) {
      $reference
        ->set('entity', $this
        ->getTargetEntity());
    }

    // Avoid custom actions for subclass WorkflowScheduledTransition.
    if ($this
      ->isScheduled()) {
      return parent::save();
    }
    if ($this
      ->getEntityTypeId() != 'workflow_transition') {
      return parent::save();
    }
    $transition = $this;
    $entity_type = $transition
      ->getTargetEntityTypeId();
    $entity_id = $transition
      ->getTargetEntityId();
    $field_name = $transition
      ->getFieldName();

    // Remove any scheduled state transitions.
    foreach (WorkflowScheduledTransition::loadMultipleByProperties($entity_type, [
      $entity_id,
    ], [], $field_name) as $scheduled_transition) {

      /** @var \Drupal\workflow\Entity\WorkflowTransitionInterface $scheduled_transition */
      $scheduled_transition
        ->delete();
    }

    // Check for no transition.
    if ($this
      ->isEmpty()) {
      return SAVED_UPDATED;
    }

    // Update the transition, if already exists.
    if ($this
      ->id()) {
      return parent::save();
    }

    // Insert the transition. Make sure it hasn't already been inserted.
    // @todo Allow a scheduled transition per revision.
    // @todo Allow a state per language version (langcode).
    $found_transition = self::loadByProperties($entity_type, $entity_id, [], $field_name);
    if ($found_transition && $found_transition
      ->getTimestamp() == \Drupal::time()
      ->getRequestTime() && $found_transition
      ->getToSid() == $this
      ->getToSid()) {
      return SAVED_UPDATED;
    }
    return parent::save();
  }

  /**
   * {@inheritdoc}
   */
  public static function loadByProperties($entity_type, $entity_id, array $revision_ids = [], $field_name = '', $langcode = '', $sort = 'ASC', $transition_type = 'workflow_transition') {
    $limit = 1;
    $transitions = self::loadMultipleByProperties($entity_type, [
      $entity_id,
    ], $revision_ids, $field_name, $langcode, $limit, $sort, $transition_type);
    if ($transitions) {
      $transition = reset($transitions);
      return $transition;
    }
    return NULL;
  }

  /**
   * {@inheritdoc}
   */
  public static function loadMultipleByProperties($entity_type, array $entity_ids, array $revision_ids = [], $field_name = '', $langcode = '', $limit = NULL, $sort = 'ASC', $transition_type = 'workflow_transition') {

    /** @var \Drupal\Core\Entity\Query\QueryInterface $query */
    $query = \Drupal::entityQuery($transition_type)
      ->condition('entity_type', $entity_type)
      ->sort('timestamp', $sort)
      ->addTag($transition_type);
    if (!empty($entity_ids)) {
      $query
        ->condition('entity_id', $entity_ids, 'IN');
    }
    if (!empty($revision_ids)) {
      $query
        ->condition('revision_id', $entity_ids, 'IN');
    }
    if ($field_name != '') {
      $query
        ->condition('field_name', $field_name, '=');
    }
    if ($langcode != '') {
      $query
        ->condition('langcode', $langcode, '=');
    }
    if ($limit) {
      $query
        ->range(0, $limit);
    }
    if ($transition_type == 'workflow_transition') {
      $query
        ->sort('hid', 'DESC');
    }
    $ids = $query
      ->execute();
    $transitions = self::loadMultiple($ids);
    return $transitions;
  }

  /**
   * Implementing interface WorkflowTransitionInterface - properties.
   */

  /**
   * Determines if the Transition is valid and can be executed.
   *
   * @todo Add to isAllowed() ?
   * @todo Add checks to WorkflowTransitionElement ?
   *
   * @return bool
   */
  public function isValid() {

    // Load the entity, if not already loaded.
    // This also sets the (empty) $revision_id in Scheduled Transitions.
    $entity = $this
      ->getTargetEntity();
    if (!$entity) {

      // @todo There is a watchdog error, but no UI-error. Is this OK?
      $message = 'User tried to execute a Transition without an entity.';
      $this
        ->logError($message);
      return FALSE;

      // <-- exit !!!
    }
    if (!$this
      ->getFromState()) {

      // @todo The page is not correctly refreshed after this error.
      $message = $this
        ->t('You tried to set a Workflow State, but
        the entity is not relevant. Please contact your system administrator.');
      $this
        ->messenger()
        ->addError($message);
      $message = 'Setting a non-relevant Entity from state %sid1 to %sid2';
      $this
        ->logError($message);
      return FALSE;

      // <-- exit !!!
    }

    // The transition is OK.
    return TRUE;
  }

  /**
   * Check if anything has changed in this transition.
   *
   * @return bool
   */
  protected function isEmpty() {
    if ($this
      ->getToSid() != $this
      ->getFromSid()) {
      return FALSE;
    }
    if ($this
      ->getComment()) {
      return FALSE;
    }
    $fields = WorkflowManager::getAttachedFields('workflow_transition', $this
      ->bundle());

    /** @var \Drupal\Core\Field\Entity\BaseFieldOverride $field */
    foreach ($fields as $field_name => $field) {
      if (!$this->{$field_name}
        ->isEmpty()) {
        return FALSE;
      }
    }
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function isAllowed(UserInterface $user, $force = FALSE) {
    if ($force) {

      // $force allows Rules to cause transition.
      return TRUE;
    }

    // @todo Keep below code aligned between WorkflowState, ~Transition, ~HistoryAccess

    /*
     * Get  user's permissions.
     */
    $type_id = $this
      ->getWorkflowId();
    if ($user
      ->hasPermission("bypass {$type_id} workflow_transition access")) {

      // Superuser is special (might be cron).
      // And $force allows Rules to cause transition.
      return TRUE;
    }

    // Determine if user is owner of the entity.
    $is_owner = WorkflowManager::isOwner($user, $this
      ->getTargetEntity());
    if ($is_owner) {
      $user
        ->addRole(WORKFLOW_ROLE_AUTHOR_RID);
    }

    /*
     * Get the object and its permissions.
     */

    /** @var \Drupal\workflow\Entity\WorkflowTransitionInterface[] $config_transitions */
    $config_transitions = $this
      ->getWorkflow()
      ->getTransitionsByStateId($this
      ->getFromSid(), $this
      ->getToSid());

    /*
     * Determine if user has Access.
     */
    $result = FALSE;
    foreach ($config_transitions as $config_transition) {
      $result = $result || $config_transition
        ->isAllowed($user, $force);
    }
    if ($result == FALSE) {

      // @todo There is a watchdog error, but no UI-error. Is this OK?
      $message = $this
        ->t('Attempt to go to nonexistent transition (from %sid1 to %sid2)');
      $this
        ->logError($message);
    }
    return $result;
  }

  /**
   * Determines if the State changes by this Transition.
   *
   * @return bool
   */
  public function hasStateChange() {
    if ($this->from_sid->target_id == $this->to_sid->target_id) {
      return FALSE;
    }
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function execute($force = FALSE) {

    // Load the entity, if not already loaded.
    // This also sets the (empty) $revision_id in Scheduled Transitions.

    /** @var \Drupal\Core\Entity\EntityInterface $entity */
    $entity = $this
      ->getTargetEntity();

    // Load explicit User object (not via $transition) for adding Role later.

    /** @var \Drupal\user\UserInterface $user */
    $user = $this
      ->getOwner();
    $from_sid = $this
      ->getFromSid();
    $to_sid = $this
      ->getToSid();
    $field_name = $this
      ->getFieldName();
    $comment = $this
      ->getComment();

    // Create a label to identify this transition,
    // even upon insert, when id() is not set, yet.
    $label = $from_sid . '-' . $to_sid;
    static $static_info = NULL;
    $entity_id = $entity
      ->id();

    // For non-default revisions, there is no way of executing the same transition twice in one call.
    // Set a random identifier since we won't be needing to access this variable later.
    if ($entity instanceof RevisionableInterface && !$entity
      ->isDefaultRevision()) {
      $entity_id = $entity_id . $entity
        ->getRevisionId();
    }
    if (isset($static_info[$entity_id][$field_name][$label]) && !$this
      ->isEmpty()) {

      // Error: this Transition is already executed.
      // On the development machine, execute() is called twice, when
      // on an Edit Page, the entity has a scheduled transition, and
      // user changes it to 'immediately'.
      // Why does this happen?? ( BTW. This happens with every submit.)
      // Remedies:
      // - search root cause of second call.
      // - try adapting code of transition->save() to avoid second record.
      // - avoid executing twice.
      $message = 'Transition is executed twice in a call. The second call for
        @entity_type %entity_id is not executed.';
      $this
        ->logError($message);

      // Return the result of the last call.
      return $static_info[$entity_id][$field_name][$label];

      // <-- exit !!!
    }

    // OK. Prepare for next round. Do not set last_sid!!
    $static_info[$entity_id][$field_name][$label] = $from_sid;

    // Make sure $force is set in the transition, too.
    if ($force) {
      $this
        ->force($force);
    }
    $force = $this
      ->isForced();

    // Store the transition(s), so it can be easily fetched later on.
    // This is a.o. used in:
    // - hook_entity_update to trigger 'transition post',
    // - hook workflow_access_node_access_records.
    $entity->workflow_transitions[$field_name] = $this;
    if (!$this
      ->isValid()) {
      return $from_sid;

      // <-- exit !!!
    }

    // @todo Move below code to $this->isAllowed().
    // If the state has changed, check the permissions.
    // No need to check if Comments or attached fields are filled.
    if ($this
      ->hasStateChange()) {

      // Make sure this transition is allowed by workflow module Admin UI.
      if (!$force) {
        $user
          ->addRole(WORKFLOW_ROLE_AUTHOR_RID);
      }
      if (!$this
        ->isAllowed($user, $force)) {
        $message = 'User %user not allowed to go from state %sid1 to %sid2';
        $this
          ->logError($message);
        return FALSE;

        // <-- exit !!!
      }

      // Make sure this transition is valid and allowed for the current user.
      // Invoke a callback indicating a transition is about to occur.
      // Modules may veto the transition by returning FALSE.
      // (Even if $force is TRUE, but they shouldn't do that.)
      // P.S. The D7 hook_workflow 'transition permitted' is removed, in favour of below hook_workflow 'transition pre'.
      $permitted = \Drupal::moduleHandler()
        ->invokeAll('workflow', [
        'transition pre',
        $this,
        $user,
      ]);

      // Stop if a module says so.
      if (in_array(FALSE, $permitted, TRUE)) {

        // @todo There is a watchdog error, but no UI-error. Is this OK?
        $message = 'Transition vetoed by module.';
        $this
          ->logError($message, 'notice');
        return FALSE;

        // <-- exit !!!
      }
    }

    /*
     * Output: process the transition.
     */
    if ($this
      ->isScheduled()) {

      /*
       * Log the transition in {workflow_transition_scheduled}.
       */
      $this
        ->save();
    }
    else {

      // The transition is allowed, but not scheduled.
      // Let other modules modify the comment.
      // The transition (in context) contains all relevant data.
      $context = [
        'transition' => $this,
      ];
      \Drupal::moduleHandler()
        ->alter('workflow_comment', $comment, $context);
      $this
        ->setComment($comment);
      $this->isExecuted = TRUE;
      if (!$this
        ->isEmpty()) {

        /*
         * Log the transition in {workflow_transition_history}.
         */
        $this
          ->save();

        // Register state change with watchdog.
        if ($this
          ->hasStateChange() && !empty($this
          ->getWorkflow()
          ->getSetting('watchdog_log'))) {
          if ($this
            ->getEntityTypeId() == 'workflow_scheduled_transition') {
            $message = 'Scheduled state change of @entity_type_label %entity_label to %sid2 executed';
          }
          else {
            $message = 'State of @entity_type_label %entity_label set to %sid2';
          }
          $this
            ->logError($message, 'notice');
        }

        // Notify modules that transition has occurred.
        // Action triggers should take place in response to this callback, not the 'transaction pre'.
        //
        // \Drupal::moduleHandler()->invokeAll('workflow', ['transition post', $this, $user]);
        // We have a problem here with Rules, Trigger, etc. when invoking
        // 'transition post': the entity has not been saved, yet. we are still
        // IN the transition, not AFTER. Alternatives:
        // 1. Save the field here explicitly, using field_attach_save;
        // 2. Move the invoke to another place: hook_entity_insert(), hook_entity_update();
        // 3. Rely on the entity hooks. This works for Rules, not for Trigger.
        // --> We choose option 2:
        // @todo D8: figure out usage of $entity->workflow_transitions[$field_name].
        // - First, $entity->workflow_transitions[] is set for easy re-fetching.
        // - Then, post_execute() is invoked via workflow_entity_insert(), _update().
      }
    }

    // Save value in static from top of this function.
    $static_info[$entity_id][$field_name][$label] = $to_sid;
    return $to_sid;
  }

  /**
   * {@inheritdoc}
   */
  public function executeAndUpdateEntity($force = FALSE) {
    $to_sid = $this
      ->getToSid();

    // Generate error and stop if transition has no new State.
    if (!$to_sid) {
      $t_args = [
        '%sid2' => $this
          ->getToState()
          ->label(),
        '%entity_label' => $this
          ->getTargetEntity()
          ->label(),
      ];
      $message = "Transition is not executed for %entity_label, since 'To' state %sid2 is invalid.";
      $this
        ->logError($message);
      $this
        ->messenger()
        ->addError($this
        ->t($message, $t_args));
      return $this
        ->getFromSid();
    }

    // Save the (scheduled) transition.
    $do_update_entity = !$this
      ->isScheduled() && !$this
      ->isExecuted();
    if ($do_update_entity) {
      $this
        ->_updateEntity();
    }
    else {

      // We create a new transition, or update an existing one.
      // Do not update the entity itself.
      // Validate transition, save in history table and delete from schedule table.
      $to_sid = $this
        ->execute($force);
    }
    return $to_sid;
  }

  /**
   * Internal function to update the Entity.
   */
  private function _updateEntity() {

    // Update the workflow field of the entity.
    $field_name = $this
      ->getFieldName();
    $entity = $this
      ->getTargetEntity();

    // N.B. Align the following functions:
    // - WorkflowDefaultWidget::massageFormValues();
    // - WorkflowManager::executeTransition().
    $entity->{$field_name}->workflow_transition = $this;
    $entity->{$field_name}->value = $this
      ->getToSid();

    // Populate the entity changed timestamp when the option is checked.
    if ($this
      ->getWorkflow()
      ->getSetting('always_update_entity')) {
      $entity->changed = $this
        ->getTimestamp();
    }
    $entity
      ->save();
  }

  /**
   * {@inheritdoc}
   */
  public function post_execute($force = FALSE) {

    // @todo D8: This function post_execute() is not yet used.
    workflow_debug(__FILE__, __FUNCTION__, __LINE__);

    // @todo D8-port: Test this snippet.
    if (!$this
      ->isEmpty()) {
      $user = $this
        ->getOwner();
      \Drupal::moduleHandler()
        ->invokeAll('workflow', [
        'transition post',
        $this,
        $user,
      ]);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function setTargetEntity(EntityInterface $entity) {
    if (!$entity) {
      $this->entity_type = '';
      $this->entity_id = '';
      $this->revision_id = '';
      $this->delta = 0;

      // Only single value is supported.
      $this->langcode = Language::LANGCODE_NOT_SPECIFIED;
      return $this;
    }

    // If Transition is added via CommentForm, use the Commented Entity.
    if ($entity
      ->getEntityTypeId() == 'comment') {

      /** @var \Drupal\comment\CommentInterface $entity */
      $entity = $entity
        ->getCommentedEntity();
    }
    $this->entity = $entity;

    /** @var \Drupal\Core\Entity\RevisionableContentEntityBase $entity */
    $this->entity_type = $entity
      ->getEntityTypeId();
    $this->entity_id = $entity
      ->id();
    $this->revision_id = $entity
      ->getRevisionId();
    $this->delta = 0;

    // Only single value is supported.
    $this->langcode = $entity
      ->language()
      ->getId();
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getTargetEntity() {

    // Use an explicit property, in case of adding new entities.
    if (isset($this->entity)) {
      return $this->entity;
    }

    // @todo D8: the following line only returns Node, not Term.

    /* return $this->entity = $this->get('entity_id')->entity; */
    $entity_type = $this
      ->getTargetEntityTypeId();
    if ($id = $this
      ->getTargetEntityId()) {
      $this->entity = \Drupal::entityTypeManager()
        ->getStorage($entity_type)
        ->load($id);
    }
    return $this->entity;
  }

  /**
   * {@inheritdoc}
   */
  public function getTargetEntityId() {
    return $this
      ->get('entity_id')->target_id;
  }

  /**
   * {@inheritdoc}
   */
  public function getTargetEntityTypeId() {
    return $this
      ->get('entity_type')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function getFieldName() {
    return $this
      ->get('field_name')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function getLangcode() {
    return $this
      ->getTargetEntity()
      ->language()
      ->getId();
  }

  /**
   * {@inheritdoc}
   */
  public function getFromState() {
    $sid = $this
      ->getFromSid();
    return $sid ? WorkflowState::load($sid) : NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function getToState() {
    $sid = $this
      ->getToSid();
    return $sid ? WorkflowState::load($sid) : NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function getFromSid() {
    $sid = $this->{'from_sid'}->target_id;
    return $sid;
  }

  /**
   * {@inheritdoc}
   */
  public function getToSid() {
    $sid = $this->{'to_sid'}->target_id;
    return $sid;
  }

  /**
   * {@inheritdoc}
   */
  public function getComment() {
    return $this
      ->get('comment')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setComment($value) {
    $this
      ->set('comment', $value);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getTimestamp() {
    return $this
      ->get('timestamp')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function getTimestampFormatted() {
    $timestamp = $this
      ->getTimestamp();
    return \Drupal::service('date.formatter')
      ->format($timestamp);
  }

  /**
   * {@inheritdoc}
   */
  public function setTimestamp($value) {
    $this
      ->set('timestamp', $value);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function isScheduled() {
    return $this->isScheduled;
  }

  /**
   * {@inheritdoc}
   */
  public function isRevertable() {

    // Some states are useless to revert.
    if ($this
      ->getFromSid() == $this
      ->getToSid()) {
      return FALSE;
    }

    // Some states are not fit to revert to.
    $from_state = $this
      ->getFromState();
    if (!$from_state || !$from_state
      ->isActive() || $from_state
      ->isCreationState()) {
      return FALSE;
    }
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function schedule($schedule = TRUE) {

    // We do a tricky thing here. The id of the entity is altered, so
    // all functions of another subclass are called.
    // $this->entityTypeId = ($schedule) ? 'workflow_scheduled_transition' : 'workflow_transition';
    //
    $this->isScheduled = $schedule;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setExecuted($isExecuted = TRUE) {
    $this->isExecuted = $isExecuted;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function isExecuted() {
    return (bool) $this->isExecuted;
  }

  /**
   * {@inheritdoc}
   */
  public function isForced() {
    return (bool) $this->isForced;
  }

  /**
   * {@inheritdoc}
   */
  public function force($force = TRUE) {
    $this->isForced = $force;
    return $this;
  }

  /**
   * Implementing interface EntityOwnerInterface. Copied from Comment.php.
   */

  /**
   * {@inheritdoc}
   */
  public function getOwner() {

    /** @var \Drupal\user\UserInterface $user */
    $user = $this
      ->get('uid')->entity;
    if (!$user || $user
      ->isAnonymous()) {
      $user = User::getAnonymousUser();
      $user
        ->setUsername(\Drupal::config('user.settings')
        ->get('anonymous'));
    }
    return $user;
  }

  /**
   * {@inheritdoc}
   */
  public function getOwnerId() {
    return $this
      ->get('uid')->target_id;
  }

  /**
   * {@inheritdoc}
   */
  public function setOwnerId($uid) {
    $this
      ->set('uid', $uid);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setOwner(UserInterface $account) {
    $this
      ->set('uid', $account
      ->id());
    return $this;
  }

  /**
   * Implementing interface FieldableEntityInterface extends EntityInterface.
   */

  /**
   * {@inheritdoc}
   */
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = [];
    $fields['hid'] = BaseFieldDefinition::create('integer')
      ->setLabel(t('Transition ID'))
      ->setDescription(t('The transition ID.'))
      ->setReadOnly(TRUE)
      ->setSetting('unsigned', TRUE);

    //    $fields['wid'] = BaseFieldDefinition::create('string')
    $fields['wid'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Workflow Type'))
      ->setDescription(t('The workflow type the transition relates to.'))
      ->setSetting('target_type', 'workflow_type')
      ->setRequired(TRUE)
      ->setTranslatable(FALSE)
      ->setRevisionable(FALSE);
    $fields['entity_type'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Entity type'))
      ->setDescription(t('The Entity type this transition belongs to.'))
      ->setSetting('is_ascii', TRUE)
      ->setSetting('max_length', EntityTypeInterface::ID_MAX_LENGTH)
      ->setReadOnly(TRUE);
    $fields['entity_id'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Entity ID'))
      ->setDescription(t('The Entity ID this record is for.'))
      ->setRequired(TRUE)
      ->setReadOnly(TRUE)
      ->setSetting('unsigned', TRUE);
    $fields['revision_id'] = BaseFieldDefinition::create('integer')
      ->setLabel(t('Revision ID'))
      ->setDescription(t('The current version identifier.'))
      ->setReadOnly(TRUE)
      ->setSetting('unsigned', TRUE);
    $fields['field_name'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Field name'))
      ->setDescription(t('The name of the field the transition relates to.'))
      ->setRequired(TRUE)
      ->setTranslatable(FALSE)
      ->setRevisionable(FALSE)
      ->setSetting('max_length', 32);
    $fields['langcode'] = BaseFieldDefinition::create('language')
      ->setLabel(t('Language'))
      ->setDescription(t('The entity language code.'))
      ->setTranslatable(TRUE)
      ->setDisplayOptions('view', [
      'region' => 'hidden',
    ])
      ->setDisplayOptions('form', [
      'type' => 'language_select',
      'weight' => 2,
    ]);
    $fields['delta'] = BaseFieldDefinition::create('integer')
      ->setLabel(t('Delta'))
      ->setDescription(t('The sequence number for this data item, used for multi-value fields.'))
      ->setReadOnly(TRUE)
      ->setSetting('unsigned', TRUE);
    $fields['from_sid'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('From state'))
      ->setDescription(t('The {workflow_states}.sid the entity started as.'))
      ->setSetting('target_type', 'workflow_state')
      ->setReadOnly(TRUE);
    $fields['to_sid'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('To state'))
      ->setDescription(t('The {workflow_states}.sid the entity transitioned to.'))
      ->setSetting('target_type', 'workflow_state')
      ->setReadOnly(TRUE);
    $fields['uid'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('User ID'))
      ->setDescription(t('The user ID of the transition author.'))
      ->setTranslatable(TRUE)
      ->setSetting('target_type', 'user')
      ->setDefaultValue(0)
      ->setRevisionable(TRUE);
    $fields['timestamp'] = BaseFieldDefinition::create('created')
      ->setLabel(t('Timestamp'))
      ->setDescription(t('The time that the current transition was executed.'))
      ->setRevisionable(TRUE);
    $fields['comment'] = BaseFieldDefinition::create('string_long')
      ->setLabel(t('Log message'))
      ->setDescription(t('The comment explaining this transition.'))
      ->setRevisionable(TRUE)
      ->setTranslatable(TRUE);
    return $fields;
  }

  /**
   * Generate a Watchdog error.
   *
   * @param $message
   * @param $type
   *   {'error' | 'notice'}
   * @param $from_sid
   * @param $to_sid
   */
  public function logError($message, $type = 'error', $from_sid = '', $to_sid = '') {

    // Prepare an array of arguments for error messages.
    $entity = $this
      ->getTargetEntity();
    $t_args = [
      /** @var \Drupal\user\UserInterface $user */
      '%user' => ($user = $this
        ->getOwner()) ? $user
        ->getDisplayName() : '',
      '%sid1' => $from_sid || !$this
        ->getFromState() ? $from_sid : $this
        ->getFromState()
        ->label(),
      '%sid2' => $to_sid || !$this
        ->getToState() ? $to_sid : $this
        ->getToState()
        ->label(),
      '%entity_id' => $this
        ->getTargetEntityId(),
      '%entity_label' => $entity ? $entity
        ->label() : '',
      '@entity_type' => $entity ? $entity
        ->getEntityTypeId() : '',
      '@entity_type_label' => $entity ? $entity
        ->getEntityType()
        ->getLabel() : '',
      'link' => $this
        ->getTargetEntityId() && $this
        ->getTargetEntity()
        ->hasLinkTemplate('canonical') ? $this
        ->getTargetEntity()
        ->toLink($this
        ->t('View'))
        ->toString() : '',
    ];
    $type == 'error' ? \Drupal::logger('workflow')
      ->error($message, $t_args) : \Drupal::logger('workflow')
      ->notice($message, $t_args);
  }

  /**
   * {@inheritdoc}
   */
  public function dpm($function = '') {
    $transition = $this;
    $entity = $transition
      ->getTargetEntity();
    $time = \Drupal::service('date.formatter')
      ->format($transition
      ->getTimestamp());

    // Do this extensive $user_name lines, for some troubles with Action.
    $user = $transition
      ->getOwner();
    $user_name = $user ? $user
      ->getAccountName() : 'unknown username';
    $t_string = $this
      ->getEntityTypeId() . ' ' . $this
      ->id() . ' for workflow_type <i>' . $this
      ->getWorkflowId() . '</i> ' . ($function ? "in function '{$function}'" : '');
    $output[] = 'Entity  = ' . $this
      ->getTargetEntityTypeId() . '/' . ($entity ? $entity
      ->bundle() . '/' . $entity
      ->id() : '___/0');
    $output[] = 'Field   = ' . $transition
      ->getFieldName();
    $output[] = 'From/To = ' . $transition
      ->getFromSid() . ' > ' . $transition
      ->getToSid() . ' @ ' . $time;
    $output[] = 'Comment = ' . $user_name . ' says: ' . $transition
      ->getComment();
    $output[] = 'Forced  = ' . ($transition
      ->isForced() ? 'yes' : 'no') . '; ' . 'Scheduled = ' . ($transition
      ->isScheduled() ? 'yes' : 'no');
    if (function_exists('dpm')) {

      // In Workflow->dpm().
      dpm($output, $t_string);

      // In Workflow->dpm().
    }

    // In Workflow->dpm().
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
ContentEntityBase::$activeLangcode protected property Language code identifying the entity active language.
ContentEntityBase::$defaultLangcode protected property Local cache for the default language code.
ContentEntityBase::$defaultLangcodeKey protected property The default langcode entity key.
ContentEntityBase::$enforceRevisionTranslationAffected protected property Whether the revision translation affected flag has been enforced.
ContentEntityBase::$entityKeys protected property Holds untranslatable entity keys such as the ID, bundle, and revision ID.
ContentEntityBase::$fieldDefinitions protected property Local cache for field definitions.
ContentEntityBase::$fields protected property The array of fields, each being an instance of FieldItemListInterface.
ContentEntityBase::$fieldsToSkipFromTranslationChangesCheck protected static property Local cache for fields to skip from the checking for translation changes.
ContentEntityBase::$isDefaultRevision protected property Indicates whether this is the default revision.
ContentEntityBase::$langcodeKey protected property The language entity key.
ContentEntityBase::$languages protected property Local cache for the available language objects.
ContentEntityBase::$loadedRevisionId protected property The loaded revision ID before the new revision was set.
ContentEntityBase::$newRevision protected property Boolean indicating whether a new revision should be created on save.
ContentEntityBase::$revisionTranslationAffectedKey protected property The revision translation affected entity key.
ContentEntityBase::$translatableEntityKeys protected property Holds translatable entity keys such as the label.
ContentEntityBase::$translationInitialize protected property A flag indicating whether a translation object is being initialized.
ContentEntityBase::$translations protected property An array of entity translation metadata.
ContentEntityBase::$validated protected property Whether entity validation was performed.
ContentEntityBase::$validationRequired protected property Whether entity validation is required before saving the entity.
ContentEntityBase::$values protected property The plain data values of the contained fields.
ContentEntityBase::access public function Checks data value access. Overrides EntityBase::access 1
ContentEntityBase::addTranslation public function Adds a new translation to the translatable object. Overrides TranslatableInterface::addTranslation
ContentEntityBase::bundle public function Gets the bundle of the entity. Overrides EntityBase::bundle
ContentEntityBase::bundleFieldDefinitions public static function Provides field definitions for a specific bundle. Overrides FieldableEntityInterface::bundleFieldDefinitions 4
ContentEntityBase::clearTranslationCache protected function Clear entity translation object cache to remove stale references.
ContentEntityBase::createDuplicate public function Creates a duplicate of the entity. Overrides EntityBase::createDuplicate 1
ContentEntityBase::get public function Gets a field item list. Overrides FieldableEntityInterface::get
ContentEntityBase::getEntityKey protected function Gets the value of the given entity key, if defined. 1
ContentEntityBase::getFieldDefinition public function Gets the definition of a contained field. Overrides FieldableEntityInterface::getFieldDefinition
ContentEntityBase::getFieldDefinitions public function Gets an array of field definitions of all contained fields. Overrides FieldableEntityInterface::getFieldDefinitions
ContentEntityBase::getFields public function Gets an array of all field item lists. Overrides FieldableEntityInterface::getFields
ContentEntityBase::getFieldsToSkipFromTranslationChangesCheck protected function Returns an array of field names to skip in ::hasTranslationChanges. 1
ContentEntityBase::getIterator public function
ContentEntityBase::getLanguages protected function
ContentEntityBase::getLoadedRevisionId public function Gets the loaded Revision ID of the entity. Overrides RevisionableInterface::getLoadedRevisionId
ContentEntityBase::getRevisionId public function Gets the revision identifier of the entity. Overrides RevisionableInterface::getRevisionId
ContentEntityBase::getTranslatableFields public function Gets an array of field item lists for translatable fields. Overrides FieldableEntityInterface::getTranslatableFields
ContentEntityBase::getTranslatedField protected function Gets a translated field.
ContentEntityBase::getTranslation public function Gets a translation of the data. Overrides TranslatableInterface::getTranslation
ContentEntityBase::getTranslationLanguages public function Returns the languages the data is translated to. Overrides TranslatableInterface::getTranslationLanguages
ContentEntityBase::getTranslationStatus public function Returns the translation status. Overrides TranslationStatusInterface::getTranslationStatus
ContentEntityBase::getUntranslated public function Returns the translatable object referring to the original language. Overrides TranslatableInterface::getUntranslated
ContentEntityBase::hasField public function Determines whether the entity has a field with the given name. Overrides FieldableEntityInterface::hasField
ContentEntityBase::hasTranslation public function Checks there is a translation for the given language code. Overrides TranslatableInterface::hasTranslation
ContentEntityBase::hasTranslationChanges public function Determines if the current translation of the entity has unsaved changes. Overrides TranslatableInterface::hasTranslationChanges
ContentEntityBase::id public function Gets the identifier. Overrides EntityBase::id
ContentEntityBase::initializeTranslation protected function Instantiates a translation object for an existing translation.
ContentEntityBase::isDefaultRevision public function Checks if this entity is the default revision. Overrides RevisionableInterface::isDefaultRevision
ContentEntityBase::isDefaultTranslation public function Checks whether the translation is the default one. Overrides TranslatableInterface::isDefaultTranslation
ContentEntityBase::isDefaultTranslationAffectedOnly public function Checks if untranslatable fields should affect only the default translation. Overrides TranslatableRevisionableInterface::isDefaultTranslationAffectedOnly
ContentEntityBase::isLatestRevision public function Checks if this entity is the latest revision. Overrides RevisionableInterface::isLatestRevision
ContentEntityBase::isLatestTranslationAffectedRevision public function Checks whether this is the latest revision affecting this translation. Overrides TranslatableRevisionableInterface::isLatestTranslationAffectedRevision
ContentEntityBase::isNewRevision public function Determines whether a new revision should be created on save. Overrides RevisionableInterface::isNewRevision
ContentEntityBase::isNewTranslation public function Checks whether the translation is new. Overrides TranslatableInterface::isNewTranslation
ContentEntityBase::isRevisionTranslationAffected public function Checks whether the current translation is affected by the current revision. Overrides TranslatableRevisionableInterface::isRevisionTranslationAffected
ContentEntityBase::isRevisionTranslationAffectedEnforced public function Checks if the revision translation affected flag value has been enforced. Overrides TranslatableRevisionableInterface::isRevisionTranslationAffectedEnforced
ContentEntityBase::isTranslatable public function Returns the translation support status. Overrides TranslatableInterface::isTranslatable
ContentEntityBase::isValidationRequired public function Checks whether entity validation is required before saving the entity. Overrides FieldableEntityInterface::isValidationRequired
ContentEntityBase::label public function Gets the label of the entity. Overrides EntityBase::label 2
ContentEntityBase::language public function Gets the language of the entity. Overrides EntityBase::language
ContentEntityBase::onChange public function Reacts to changes to a field. Overrides FieldableEntityInterface::onChange
ContentEntityBase::postCreate public function Acts on a created entity before hooks are invoked. Overrides EntityBase::postCreate
ContentEntityBase::postSave public function Acts on a saved entity before the insert or update hook is invoked. Overrides EntityBase::postSave 5
ContentEntityBase::preSave public function Acts on an entity before the presave hook is invoked. Overrides EntityBase::preSave 5
ContentEntityBase::preSaveRevision public function Acts on a revision before it gets saved. Overrides RevisionableInterface::preSaveRevision 2
ContentEntityBase::referencedEntities public function Gets a list of entities referenced by this entity. Overrides EntityBase::referencedEntities 1
ContentEntityBase::removeTranslation public function Removes the translation identified by the given language code. Overrides TranslatableInterface::removeTranslation
ContentEntityBase::set public function Sets a field value. Overrides FieldableEntityInterface::set
ContentEntityBase::setDefaultLangcode protected function Populates the local cache for the default language code.
ContentEntityBase::setNewRevision public function Enforces an entity to be saved as a new revision. Overrides RevisionableInterface::setNewRevision
ContentEntityBase::setRevisionTranslationAffected public function Marks the current revision translation as affected. Overrides TranslatableRevisionableInterface::setRevisionTranslationAffected
ContentEntityBase::setRevisionTranslationAffectedEnforced public function Enforces the revision translation affected flag value. Overrides TranslatableRevisionableInterface::setRevisionTranslationAffectedEnforced
ContentEntityBase::setValidationRequired public function Sets whether entity validation is required before saving the entity. Overrides FieldableEntityInterface::setValidationRequired
ContentEntityBase::toArray public function Gets an array of all property values. Overrides EntityBase::toArray
ContentEntityBase::updateFieldLangcodes protected function Updates language for already instantiated fields.
ContentEntityBase::updateLoadedRevisionId public function Updates the loaded Revision ID with the revision ID. Overrides RevisionableInterface::updateLoadedRevisionId
ContentEntityBase::updateOriginalValues public function Updates the original values with the interim changes.
ContentEntityBase::uuid public function Gets the entity UUID (Universally Unique Identifier). Overrides EntityBase::uuid
ContentEntityBase::validate public function Validates the currently set values. Overrides FieldableEntityInterface::validate
ContentEntityBase::wasDefaultRevision public function Checks whether the entity object was a default revision when it was saved. Overrides RevisionableInterface::wasDefaultRevision
ContentEntityBase::__clone public function Magic method: Implements a deep clone.
ContentEntityBase::__get public function Implements the magic method for getting object properties.
ContentEntityBase::__isset public function Implements the magic method for isset().
ContentEntityBase::__set public function Implements the magic method for setting object properties.
ContentEntityBase::__sleep public function Overrides EntityBase::__sleep
ContentEntityBase::__unset public function Implements the magic method for unset().
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function Aliased as: traitSleep 1
DependencySerializationTrait::__wakeup public function 2
EntityBase::$enforceIsNew protected property Boolean indicating whether the entity should be forced to be new.
EntityBase::$entityTypeId protected property The entity type.
EntityBase::$typedData protected property A typed data object wrapping this entity.
EntityBase::delete public function Deletes an entity permanently. Overrides EntityInterface::delete 2
EntityBase::enforceIsNew public function Enforces an entity to be new. Overrides EntityInterface::enforceIsNew
EntityBase::entityManager Deprecated protected function Gets the entity manager.
EntityBase::entityTypeBundleInfo protected function Gets the entity type bundle info service.
EntityBase::entityTypeManager protected function Gets the entity type manager.
EntityBase::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyTrait::getCacheContexts
EntityBase::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyTrait::getCacheMaxAge
EntityBase::getCacheTags public function The cache tags associated with this object. Overrides CacheableDependencyTrait::getCacheTags
EntityBase::getCacheTagsToInvalidate public function Returns the cache tags that should be used to invalidate caches. Overrides EntityInterface::getCacheTagsToInvalidate 2
EntityBase::getConfigDependencyKey public function Gets the key that is used to store configuration dependencies. Overrides EntityInterface::getConfigDependencyKey
EntityBase::getConfigDependencyName public function Gets the configuration dependency name. Overrides EntityInterface::getConfigDependencyName 1
EntityBase::getConfigTarget public function Gets the configuration target identifier for the entity. Overrides EntityInterface::getConfigTarget 1
EntityBase::getEntityType public function Gets the entity type definition. Overrides EntityInterface::getEntityType
EntityBase::getEntityTypeId public function Gets the ID of the type of the entity. Overrides EntityInterface::getEntityTypeId
EntityBase::getListCacheTagsToInvalidate protected function The list cache tags to invalidate for this entity.
EntityBase::getOriginalId public function Gets the original ID. Overrides EntityInterface::getOriginalId 1
EntityBase::getTypedData public function Gets a typed data object for this entity object. Overrides EntityInterface::getTypedData
EntityBase::hasLinkTemplate public function Indicates if a link template exists for a given key. Overrides EntityInterface::hasLinkTemplate
EntityBase::invalidateTagsOnDelete protected static function Invalidates an entity's cache tags upon delete. 1
EntityBase::invalidateTagsOnSave protected function Invalidates an entity's cache tags upon save. 1
EntityBase::isNew public function Determines whether the entity is new. Overrides EntityInterface::isNew 2
EntityBase::languageManager protected function Gets the language manager.
EntityBase::link public function Deprecated way of generating a link to the entity. See toLink(). Overrides EntityInterface::link 1
EntityBase::linkTemplates protected function Gets an array link templates. 1
EntityBase::load public static function Loads an entity. Overrides EntityInterface::load
EntityBase::loadMultiple public static function Loads one or more entities. Overrides EntityInterface::loadMultiple
EntityBase::postDelete public static function Acts on deleted entities before the delete hook is invoked. Overrides EntityInterface::postDelete 16
EntityBase::postLoad public static function Acts on loaded entities. Overrides EntityInterface::postLoad 2
EntityBase::preCreate public static function Changes the values of an entity before it is created. Overrides EntityInterface::preCreate 5
EntityBase::preDelete public static function Acts on entities before they are deleted and before hooks are invoked. Overrides EntityInterface::preDelete 4
EntityBase::setOriginalId public function Sets the original ID. Overrides EntityInterface::setOriginalId 1
EntityBase::toLink public function Generates the HTML for a link to this entity. Overrides EntityInterface::toLink
EntityBase::toUrl public function Gets the URL object for the entity. Overrides EntityInterface::toUrl 2
EntityBase::uriRelationships public function Gets a list of URI relationships supported by this entity. Overrides EntityInterface::uriRelationships
EntityBase::url public function Gets the public URL for this entity. Overrides EntityInterface::url 2
EntityBase::urlInfo public function Gets the URL object for the entity. Overrides EntityInterface::urlInfo 1
EntityBase::urlRouteParameters protected function Gets an array of placeholders for this entity. 2
EntityBase::uuidGenerator protected function Gets the UUID generator.
EntityChangesDetectionTrait::getFieldsToSkipFromTranslationChangesCheck protected function Returns an array of field names to skip when checking for changes. Aliased as: traitGetFieldsToSkipFromTranslationChangesCheck
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
SynchronizableEntityTrait::$isSyncing protected property Whether this entity is being created, updated or deleted through a synchronization process.
SynchronizableEntityTrait::isSyncing public function
SynchronizableEntityTrait::setSyncing public function
TranslationStatusInterface::TRANSLATION_CREATED constant Status code identifying a newly created translation.
TranslationStatusInterface::TRANSLATION_EXISTING constant Status code identifying an existing translation.
TranslationStatusInterface::TRANSLATION_REMOVED constant Status code identifying a removed translation.
WorkflowTransition::$entity protected property @usage Use WorkflowTransition->getTargetEntity() to fetch this.
WorkflowTransition::$isExecuted protected property Extra data: describe the state of the transition.
WorkflowTransition::$isForced protected property Extra data: describe the state of the transition.
WorkflowTransition::$isScheduled protected property Extra data: describe the state of the transition.
WorkflowTransition::$user protected property @usage Use WorkflowTransition->getOwner() to fetch this.
WorkflowTransition::baseFieldDefinitions public static function Provides base field definitions for an entity type. Overrides ContentEntityBase::baseFieldDefinitions 1
WorkflowTransition::create public static function Overrides EntityBase::create
WorkflowTransition::dpm public function Helper/debugging function. Shows simple contents of Transition. Overrides WorkflowTransitionInterface::dpm
WorkflowTransition::execute public function Execute a transition (change state of an entity). Overrides WorkflowTransitionInterface::execute
WorkflowTransition::executeAndUpdateEntity public function Executes a transition (change state of an entity), from OUTSIDE the entity. Overrides WorkflowTransitionInterface::executeAndUpdateEntity
WorkflowTransition::force public function Set if a transition must be executed, even if transition is invalid or user not authorized. Overrides WorkflowTransitionInterface::force
WorkflowTransition::getComment public function Get the comment of the Transition. Overrides WorkflowTransitionInterface::getComment
WorkflowTransition::getFieldName public function Get the field_name for which the Transition is valid. Overrides WorkflowTransitionInterface::getFieldName
WorkflowTransition::getFromSid public function Overrides WorkflowConfigTransitionInterface::getFromSid
WorkflowTransition::getFromState public function Overrides WorkflowConfigTransitionInterface::getFromState
WorkflowTransition::getLangcode public function Get the language code for which the Transition is valid. Overrides WorkflowTransitionInterface::getLangcode
WorkflowTransition::getOwner public function Returns the entity owner's user entity. Overrides EntityOwnerInterface::getOwner
WorkflowTransition::getOwnerId public function Returns the entity owner's user ID. Overrides EntityOwnerInterface::getOwnerId
WorkflowTransition::getTargetEntity public function Returns the entity to which the workflow is attached. Overrides WorkflowTransitionInterface::getTargetEntity
WorkflowTransition::getTargetEntityId public function Returns the ID of the entity to which the workflow is attached. Overrides WorkflowTransitionInterface::getTargetEntityId
WorkflowTransition::getTargetEntityTypeId public function Returns the type of the entity to which the workflow is attached. Overrides WorkflowTransitionInterface::getTargetEntityTypeId
WorkflowTransition::getTimestamp public function Returns the time on which the transitions was or will be executed. Overrides WorkflowTransitionInterface::getTimestamp
WorkflowTransition::getTimestampFormatted public function Returns the human-readable time. Overrides WorkflowTransitionInterface::getTimestampFormatted
WorkflowTransition::getToSid public function Overrides WorkflowConfigTransitionInterface::getToSid
WorkflowTransition::getToState public function Overrides WorkflowConfigTransitionInterface::getToState
WorkflowTransition::hasStateChange public function Determines if the State changes by this Transition. Overrides WorkflowConfigTransitionInterface::hasStateChange
WorkflowTransition::isAllowed public function Determines if the current transition between 2 states is allowed. Overrides WorkflowConfigTransitionInterface::isAllowed
WorkflowTransition::isEmpty protected function Check if anything has changed in this transition.
WorkflowTransition::isExecuted public function Returns if this is an Executed Transition. Overrides WorkflowTransitionInterface::isExecuted
WorkflowTransition::isForced public function A transition may be forced skipping checks. Overrides WorkflowTransitionInterface::isForced
WorkflowTransition::isRevertable public function Returns if this is a revertable Transition on the History tab. Overrides WorkflowTransitionInterface::isRevertable
WorkflowTransition::isScheduled public function Returns if this is a Scheduled Transition. Overrides WorkflowTransitionInterface::isScheduled
WorkflowTransition::isValid public function Determines if the Transition is valid and can be executed.
WorkflowTransition::loadByProperties public static function Load (Scheduled) WorkflowTransitions, most recent first. Overrides WorkflowTransitionInterface::loadByProperties 1
WorkflowTransition::loadMultipleByProperties public static function Given an entity, get all transitions for it. Overrides WorkflowTransitionInterface::loadMultipleByProperties 1
WorkflowTransition::logError public function Generate a Watchdog error.
WorkflowTransition::post_execute public function Invokes 'transition post'. Overrides WorkflowTransitionInterface::post_execute
WorkflowTransition::save public function Saves the entity. Overrides EntityBase::save 1
WorkflowTransition::schedule public function Sets the Transition to be scheduled or not. Overrides WorkflowTransitionInterface::schedule
WorkflowTransition::setComment public function Get the comment of the Transition. Overrides WorkflowTransitionInterface::setComment
WorkflowTransition::setExecuted public function Set the 'isExecuted' property. Overrides WorkflowTransitionInterface::setExecuted
WorkflowTransition::setOwner public function Sets the entity owner's user entity. Overrides EntityOwnerInterface::setOwner
WorkflowTransition::setOwnerId public function Sets the entity owner's user ID. Overrides EntityOwnerInterface::setOwnerId
WorkflowTransition::setTargetEntity public function Sets the Entity, that is added to the Transition. Overrides WorkflowTransitionInterface::setTargetEntity
WorkflowTransition::setTimestamp public function Returns the time on which the transitions was or will be executed. Overrides WorkflowTransitionInterface::setTimestamp
WorkflowTransition::setValues public function Helper function for __construct. Used for all children of WorkflowTransition (aka WorkflowScheduledTransition) Overrides WorkflowTransitionInterface::setValues 1
WorkflowTransition::_updateEntity private function Internal function to update the Entity.
WorkflowTransition::__construct public function Creates a new entity. Overrides ContentEntityBase::__construct 1
WorkflowTypeAttributeTrait::$wid protected property The machine_name of the attached Workflow.
WorkflowTypeAttributeTrait::$workflow protected property The attached Workflow.
WorkflowTypeAttributeTrait::getWorkflow public function Returns the Workflow object of this object.
WorkflowTypeAttributeTrait::getWorkflowId public function Returns the Workflow ID of this object.
WorkflowTypeAttributeTrait::setWorkflow public function
WorkflowTypeAttributeTrait::setWorkflowId public function Sets the Workflow ID of this object.