You are here

interface WorkflowTransitionInterface in Workflow 8

Defines a common interface for Workflow*Transition* objects.

Hierarchy

Expanded class hierarchy of WorkflowTransitionInterface

All classes that implement WorkflowTransitionInterface

See also

\Drupal\workflow\Entity\WorkflowConfigTransition

\Drupal\workflow\Entity\WorkflowTransition

\Drupal\workflow\Entity\WorkflowScheduledTransition

5 files declare their use of WorkflowTransitionInterface
workflow.api.php in ./workflow.api.php
Hooks provided by the workflow module.
workflow.form.inc in ./workflow.form.inc
Contains helper functions for WorkflowTransitionForm.
workflow.module in ./workflow.module
Support workflows made up of arbitrary states.
WorkflowTransitionRevertForm.php in src/Form/WorkflowTransitionRevertForm.php
workflow_devel.module in modules/workflow_devel/workflow_devel.module
Development tools for Workflow.

File

src/Entity/WorkflowTransitionInterface.php, line 16

Namespace

Drupal\workflow\Entity
View source
interface WorkflowTransitionInterface extends WorkflowConfigTransitionInterface, FieldableEntityInterface, EntityOwnerInterface {

  /**
   * Helper function for __construct. Used for all children of WorkflowTransition (aka WorkflowScheduledTransition)
   *
   * Usage:
   *   $transition = WorkflowTransition::create([$current_sid, 'field_name' => $field_name]);
   *   $transition->setTargetEntity($entity);
   *   $transition->setValues($new_sid, $user->id(), REQUEST_TIME, $comment);
   *
   * @param string $to_sid
   * @param int $uid
   * @param int $timestamp
   * @param string $comment
   * @param bool $force_create
   */
  public function setValues($to_sid, $uid = NULL, $timestamp = NULL, $comment = '', $force_create = FALSE);

  /**
   * Load (Scheduled) WorkflowTransitions, most recent first.
   *
   * @param string $entity_type
   * @param int $entity_id
   * @param array $revision_ids
   * @param string $field_name
   * @param string $langcode
   * @param string $sort
   * @param string $transition_type
   *
   * @return \Drupal\workflow\Entity\WorkflowTransitionInterface
   *   Object representing one row from the {workflow_transition_history} table.
   */
  public static function loadByProperties($entity_type, $entity_id, array $revision_ids = [], $field_name = '', $langcode = '', $sort = 'ASC', $transition_type = '');

  /**
   * Given an entity, get all transitions for it.
   *
   * Since this may return a lot of data, a limit is included to allow for only one result.
   *
   * @param string $entity_type
   * @param int[] $entity_ids
   * @param int[] $revision_ids
   * @param string $field_name
   *   Optional. Can be NULL, if you want to load any field.
   * @param string $langcode
   *   Optional. Can be empty, if you want to load any language.
   * @param int $limit
   *   Optional. Can be NULL, if you want to load all transitions.
   * @param string $sort
   *   Optional sort order {'ASC'|'DESC'}.
   * @param string $transition_type
   *   The type of the transition to be fetched.
   *
   * @return WorkflowTransitionInterface[]
   *   An array of transitions.
   */
  public static function loadMultipleByProperties($entity_type, array $entity_ids, array $revision_ids = [], $field_name = '', $langcode = '', $limit = NULL, $sort = 'ASC', $transition_type = '');

  /**
   * Execute a transition (change state of an entity).
   *
   * A Scheduled Transition shall only be saved, unless the
   * 'schedule' property is set.
   *
   * @param bool $force
   *   If set to TRUE, workflow permissions will be ignored.
   *
   * @return string
   *   New state ID. If execution failed, old state ID is returned,
   *
   * @usage
   *   $transition->schedule(FALSE);
   *   $to_sid = $transition->execute(TRUE);
   */
  public function execute($force = FALSE);

  /**
   * Executes a transition (change state of an entity), from OUTSIDE the entity.
   *
   * Use $transition->executeAndUpdateEntity() to start a State Change from
   *   outside an entity, e.g., workflow_cron().
   * Use $transition->execute() to start a State Change from within an entity.
   *
   * A Scheduled Transition ($transition->isScheduled() == TRUE) will be
   *   un-scheduled and saved in the history table.
   *   The entity will not be updated.
   * If $transition->isScheduled() == FALSE, the Transition will be
   *   removed from the {workflow_transition_scheduled} table (if necessary),
   *   and added to {workflow_transition_history} table.
   *   Then the entity wil be updated to reflect the new status.
   *
   * @param bool $force
   *   If set to TRUE, workflow permissions will be ignored.
   *
   * @return string
   *   The resulting WorkflowState id.
   *
   * @usage
   *   $to_sid = $transition->->executeAndUpdateEntity($force);
   *
   * @see workflow_execute_transition()
   */
  public function executeAndUpdateEntity($force = FALSE);

  /**
   * Invokes 'transition post'.
   *
   * Adds the possibility to invoke the hook from elsewhere.
   *
   * @param bool $force
   */
  public function post_execute($force = FALSE);

  /**
   * Sets the Entity, that is added to the Transition.
   *
   * Also sets all dependent fields, that will be saved in tables {workflow_transition_*}.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The Entity ID or the Entity object, to add to the Transition.
   *
   * @return object
   *   The Entity, that is added to the Transition.
   */
  public function setTargetEntity(EntityInterface $entity);

  /**
   * Returns the entity to which the workflow is attached.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   *   The entity to which the workflow is attached.
   */
  public function getTargetEntity();

  /**
   * Returns the ID of the entity to which the workflow is attached.
   *
   * @return int
   *   The ID of the entity to which the workflow is attached.
   */
  public function getTargetEntityId();

  /**
   * Returns the type of the entity to which the workflow is attached.
   *
   * @return string
   *   An entity type.
   */
  public function getTargetEntityTypeId();

  /**
   * Get the field_name for which the Transition is valid.
   *
   * @return string
   *   The field_name, that is added to the Transition.
   */
  public function getFieldName();

  /**
   * Get the language code for which the Transition is valid.
   *
   * @return string
   *   $langcode
   *
   * @todo OK?? Shouldn't we use entity's language() method for langcode?
   */
  public function getLangcode();

  /**
   * Get the comment of the Transition.
   *
   * @return
   *   The comment
   */
  public function getComment();

  /**
   * Get the comment of the Transition.
   *
   * @param $value
   *   The new comment.
   *
   * @return WorkflowTransitionInterface
   */
  public function setComment($value);

  /**
   * Returns the time on which the transitions was or will be executed.
   *
   * @return
   */
  public function getTimestamp();

  /**
   * Returns the human-readable time.
   *
   * @return string
   */
  public function getTimestampFormatted();

  /**
   * Returns the time on which the transitions was or will be executed.
   *
   * @param $value
   *   The new timestamp.
   *
   * @return WorkflowTransitionInterface
   */
  public function setTimestamp($value);

  /**
   * Returns if this is a Scheduled Transition.
   *
   * @return bool
   */
  public function isScheduled();

  /**
   * Returns if this is a revertable Transition on the History tab.
   *
   * @return bool
   */
  public function isRevertable();

  /**
   * Sets the Transition to be scheduled or not.
   *
   * @param bool $schedule
   *
   * @return WorkflowTransitionInterface
   */
  public function schedule($schedule = TRUE);

  /**
   * Set the 'isExecuted' property.
   *
   * @param bool $isExecuted
   *
   * @return WorkflowTransitionInterface
   */
  public function setExecuted($isExecuted = TRUE);

  /**
   * Returns if this is an Executed Transition.
   *
   * @return bool
   */
  public function isExecuted();

  /**
   * A transition may be forced skipping checks.
   *
   * @return bool
   *   If the transition is forced. (Allow not-configured transitions).
   */
  public function isForced();

  /**
   * Set if a transition must be executed, even if transition is invalid or user not authorized.
   *
   * @param bool $force
   *
   * @return object
   *   The transition itself.
   */
  public function force($force = TRUE);

  /**
   * Helper/debugging function. Shows simple contents of Transition.
   *
   * @param string $function
   */
  public function dpm($function = '');

}

Members

Namesort descending Modifiers Type Description Overrides
AccessibleInterface::access public function Checks data value access. 9
CacheableDependencyInterface::getCacheContexts public function The cache contexts associated with this object. 34
CacheableDependencyInterface::getCacheMaxAge public function The maximum age for which this object may be cached. 34
CacheableDependencyInterface::getCacheTags public function The cache tags associated with this object. 27
EntityInterface::bundle public function Gets the bundle of the entity. 2
EntityInterface::create public static function Constructs a new entity object, without permanently saving it. 2
EntityInterface::createDuplicate public function Creates a duplicate of the entity. 2
EntityInterface::delete public function Deletes an entity permanently. 2
EntityInterface::enforceIsNew public function Enforces an entity to be new. 2
EntityInterface::getCacheTagsToInvalidate public function Returns the cache tags that should be used to invalidate caches. 2
EntityInterface::getConfigDependencyKey public function Gets the key that is used to store configuration dependencies. 2
EntityInterface::getConfigDependencyName public function Gets the configuration dependency name. 2
EntityInterface::getConfigTarget public function Gets the configuration target identifier for the entity. 2
EntityInterface::getEntityType public function Gets the entity type definition. 2
EntityInterface::getEntityTypeId public function Gets the ID of the type of the entity. 2
EntityInterface::getOriginalId public function Gets the original ID. 2
EntityInterface::getTypedData public function Gets a typed data object for this entity object. 2
EntityInterface::hasLinkTemplate public function Indicates if a link template exists for a given key. 2
EntityInterface::id public function Gets the identifier. 2
EntityInterface::isNew public function Determines whether the entity is new. 2
EntityInterface::label public function Gets the label of the entity. 2
EntityInterface::language public function Gets the language of the entity. 2
EntityInterface::link Deprecated public function Deprecated way of generating a link to the entity. See toLink(). 2
EntityInterface::load public static function Loads an entity. 2
EntityInterface::loadMultiple public static function Loads one or more entities. 2
EntityInterface::postCreate public function Acts on a created entity before hooks are invoked. 2
EntityInterface::postDelete public static function Acts on deleted entities before the delete hook is invoked. 2
EntityInterface::postLoad public static function Acts on loaded entities. 3
EntityInterface::postSave public function Acts on a saved entity before the insert or update hook is invoked. 2
EntityInterface::preCreate public static function Changes the values of an entity before it is created. 2
EntityInterface::preDelete public static function Acts on entities before they are deleted and before hooks are invoked. 2
EntityInterface::preSave public function Acts on an entity before the presave hook is invoked. 2
EntityInterface::referencedEntities public function Gets a list of entities referenced by this entity. 2
EntityInterface::save public function Saves an entity permanently. 2
EntityInterface::setOriginalId public function Sets the original ID. 2
EntityInterface::toLink public function Generates the HTML for a link to this entity. 2
EntityInterface::toUrl public function Gets the URL object for the entity. 2
EntityInterface::uriRelationships public function Gets a list of URI relationships supported by this entity. 2
EntityInterface::url Deprecated public function Gets the public URL for this entity. 2
EntityInterface::urlInfo Deprecated public function Gets the URL object for the entity. 2
EntityInterface::uuid public function Gets the entity UUID (Universally Unique Identifier). 2
EntityOwnerInterface::getOwner public function Returns the entity owner's user entity. 1
EntityOwnerInterface::getOwnerId public function Returns the entity owner's user ID. 1
EntityOwnerInterface::setOwner public function Sets the entity owner's user entity. 1
EntityOwnerInterface::setOwnerId public function Sets the entity owner's user ID. 1
FieldableEntityInterface::baseFieldDefinitions public static function Provides base field definitions for an entity type. 2
FieldableEntityInterface::bundleFieldDefinitions public static function Provides field definitions for a specific bundle. 2
FieldableEntityInterface::get public function Gets a field item list. 1
FieldableEntityInterface::getFieldDefinition public function Gets the definition of a contained field. 1
FieldableEntityInterface::getFieldDefinitions public function Gets an array of field definitions of all contained fields. 1
FieldableEntityInterface::getFields public function Gets an array of all field item lists. 1
FieldableEntityInterface::getTranslatableFields public function Gets an array of field item lists for translatable fields. 1
FieldableEntityInterface::hasField public function Determines whether the entity has a field with the given name. 1
FieldableEntityInterface::isValidationRequired public function Checks whether entity validation is required before saving the entity. 1
FieldableEntityInterface::onChange public function Reacts to changes to a field. 1
FieldableEntityInterface::set public function Sets a field value. 1
FieldableEntityInterface::setValidationRequired public function Sets whether entity validation is required before saving the entity. 1
FieldableEntityInterface::toArray public function Gets an array of all field values. Overrides EntityInterface::toArray
FieldableEntityInterface::validate public function Validates the currently set values. 1
RefinableCacheableDependencyInterface::addCacheableDependency public function Adds a dependency on an object: merges its cacheability metadata. 1
RefinableCacheableDependencyInterface::addCacheContexts public function Adds cache contexts. 1
RefinableCacheableDependencyInterface::addCacheTags public function Adds cache tags. 1
RefinableCacheableDependencyInterface::mergeCacheMaxAge public function Merges the maximum age (in seconds) with the existing maximum age. 1
WorkflowConfigTransitionInterface::getFromSid public function 2
WorkflowConfigTransitionInterface::getFromState public function 2
WorkflowConfigTransitionInterface::getToSid public function 2
WorkflowConfigTransitionInterface::getToState public function 2
WorkflowConfigTransitionInterface::getWorkflow public function Returns the Workflow object of this object.
WorkflowConfigTransitionInterface::getWorkflowId public function Returns the Workflow ID of this object.
WorkflowConfigTransitionInterface::hasStateChange public function Determines if the State changes by this Transition. 2
WorkflowConfigTransitionInterface::isAllowed public function Determines if the current transition between 2 states is allowed. 2
WorkflowTransitionInterface::dpm public function Helper/debugging function. Shows simple contents of Transition. 1
WorkflowTransitionInterface::execute public function Execute a transition (change state of an entity). 1
WorkflowTransitionInterface::executeAndUpdateEntity public function Executes a transition (change state of an entity), from OUTSIDE the entity. 1
WorkflowTransitionInterface::force public function Set if a transition must be executed, even if transition is invalid or user not authorized. 1
WorkflowTransitionInterface::getComment public function Get the comment of the Transition. 1
WorkflowTransitionInterface::getFieldName public function Get the field_name for which the Transition is valid. 1
WorkflowTransitionInterface::getLangcode public function Get the language code for which the Transition is valid. 1
WorkflowTransitionInterface::getTargetEntity public function Returns the entity to which the workflow is attached. 1
WorkflowTransitionInterface::getTargetEntityId public function Returns the ID of the entity to which the workflow is attached. 1
WorkflowTransitionInterface::getTargetEntityTypeId public function Returns the type of the entity to which the workflow is attached. 1
WorkflowTransitionInterface::getTimestamp public function Returns the time on which the transitions was or will be executed. 1
WorkflowTransitionInterface::getTimestampFormatted public function Returns the human-readable time. 1
WorkflowTransitionInterface::isExecuted public function Returns if this is an Executed Transition. 1
WorkflowTransitionInterface::isForced public function A transition may be forced skipping checks. 1
WorkflowTransitionInterface::isRevertable public function Returns if this is a revertable Transition on the History tab. 1
WorkflowTransitionInterface::isScheduled public function Returns if this is a Scheduled Transition. 1
WorkflowTransitionInterface::loadByProperties public static function Load (Scheduled) WorkflowTransitions, most recent first. 1
WorkflowTransitionInterface::loadMultipleByProperties public static function Given an entity, get all transitions for it. 1
WorkflowTransitionInterface::post_execute public function Invokes 'transition post'. 1
WorkflowTransitionInterface::schedule public function Sets the Transition to be scheduled or not. 1
WorkflowTransitionInterface::setComment public function Get the comment of the Transition. 1
WorkflowTransitionInterface::setExecuted public function Set the 'isExecuted' property. 1
WorkflowTransitionInterface::setTargetEntity public function Sets the Entity, that is added to the Transition. 1
WorkflowTransitionInterface::setTimestamp public function Returns the time on which the transitions was or will be executed. 1
WorkflowTransitionInterface::setValues public function Helper function for __construct. Used for all children of WorkflowTransition (aka WorkflowScheduledTransition) 1