You are here

public function WorkflowTransition::setEntity in Workflow 7.2

Same name and namespace in other branches
  1. 7 includes/Entity/WorkflowTransition.php \WorkflowTransition::setEntity()

Set the Transitions $entity.

Parameters

string $entity_type: The entity type of the entity.

mixed $entity: The Entity ID or the Entity object, to add to the Transition.

Return value

object $entity The Entity, that is added to the Transition.

1 call to WorkflowTransition::setEntity()
WorkflowTransition::setValues in includes/Entity/WorkflowTransition.php
Helper function for __construct. Used for all children of WorkflowTransition (aka WorkflowScheduledTransition)

File

includes/Entity/WorkflowTransition.php, line 564
Contains workflow\includes\Entity\WorkflowTransition. Contains workflow\includes\Entity\WorkflowTransitionController.

Class

WorkflowTransition
Implements an actual Transition.

Code

public function setEntity($entity_type, $entity) {
  if (!is_object($entity)) {
    $entity_id = $entity;

    // Use node API or Entity API to load the object first.
    $entity = entity_load_single($entity_type, $entity_id);
  }
  $this->entity = $entity;
  $this->entity_type = $entity_type;
  list($this->entity_id, $this->revision_id, ) = entity_extract_ids($entity_type, $entity);

  // For backwards compatibility, set nid.
  $this->nid = $this->entity_id;
  return $this->entity;
}