You are here

public function WorkflowTransition::getTargetEntity in Workflow 8

Returns the entity to which the workflow is attached.

Return value

\Drupal\Core\Entity\EntityInterface The entity to which the workflow is attached.

Overrides WorkflowTransitionInterface::getTargetEntity

8 calls to WorkflowTransition::getTargetEntity()
WorkflowScheduledTransition::save in src/Entity/WorkflowScheduledTransition.php
Saves a scheduled transition. If the transition is executed, save in history.
WorkflowTransition::execute in src/Entity/WorkflowTransition.php
Execute a transition (change state of an entity).
WorkflowTransition::isAllowed in src/Entity/WorkflowTransition.php
Determines if the current transition between 2 states is allowed.
WorkflowTransition::isValid in src/Entity/WorkflowTransition.php
Determines if the Transition is valid and can be executed.
WorkflowTransition::logError in src/Entity/WorkflowTransition.php
Generate a Watchdog error.

... See full list

File

src/Entity/WorkflowTransition.php, line 684

Class

WorkflowTransition
Implements an actual, executed, Transition.

Namespace

Drupal\workflow\Entity

Code

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;
}