You are here

interface WorkflowInterface in Workflow 8

Defines a common interface for Workflow*Transition* objects.

Hierarchy

Expanded class hierarchy of WorkflowInterface

All classes that implement WorkflowInterface

See also

\Drupal\workflow\Entity\WorkflowConfigTransition

\Drupal\workflow\Entity\WorkflowTransition

\Drupal\workflow\Entity\WorkflowScheduledTransition

File

src/Entity/WorkflowInterface.php, line 15

Namespace

Drupal\workflow\Entity
View source
interface WorkflowInterface {

  /**
   * Returns the workflow id.
   *
   * @return string
   *   $wid
   */
  public function getWorkflowId();

  /**
   * Validate the workflow. Generate a message if not correct.
   *
   * This function is used on the settings page of:
   * - Workflow field: WorkflowItem->settingsForm()
   *
   * @return bool
   *   $is_valid
   */
  public function isValid();

  /**
   * Returns if the Workflow may be deleted.
   *
   * @return bool
   *   TRUE if a Workflow may safely be deleted.
   */
  public function isDeletable();

  /**
   * Create a new state for this workflow.
   *
   * @param string $sid
   * @param bool $save
   *   Indicator if the new state must be saved. Normally, the new State is
   *   saved directly in the database. This is because you can use States only
   *   with Transitions, and they rely on State IDs which are generated
   *   magically when saving the State. But you may need a temporary state.
   *
   * @return \Drupal\workflow\Entity\WorkflowState
   *   The new state.
   */
  public function createState($sid, $save = TRUE);

  /**
   * Gets the initial state for a newly created entity.
   */
  public function getCreationState();

  /**
   * Gets the ID of the initial state for a newly created entity.
   */
  public function getCreationSid();

  /**
   * Gets the first valid state ID, after the creation state.
   *
   * Uses WorkflowState::getOptions(), because this does an access check.
   * The first State ID is user-dependent!
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity at hand. May be NULL (E.g., on a Field settings page).
   * @param string $field_name
   * @param \Drupal\Core\Session\AccountInterface $user
   * @param bool $force
   *
   * @return string
   *   A State ID.
   */
  public function getFirstSid(EntityInterface $entity, $field_name, AccountInterface $user, $force = FALSE);

  /**
   * Returns the next state for the current state.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity at hand.
   * @param string $field_name
   * @param \Drupal\Core\Session\AccountInterface $user
   * @param bool $force
   *
   * @return string
   *   A State ID.
   *
   * @usage Is used in VBO Bulk actions.
   */
  public function getNextSid(EntityInterface $entity, $field_name, AccountInterface $user, $force = FALSE);

  /**
   * Gets all states for a given workflow.
   *
   * @param mixed $all
   *   Indicates to which states to return.
   *   - TRUE = all, including Creation and Inactive;
   *   - FALSE = only Active states, not Creation;
   *   - 'CREATION' = only Active states, including Creation.
   * @param bool $reset
   *
   * @return \Drupal\workflow\Entity\WorkflowState[]
   *   An array of WorkflowState objects.
   */
  public function getStates($all = FALSE, $reset = FALSE);

  /**
   * Gets a state for a given workflow.
   *
   * @param string $sid
   *   A state ID.
   *
   * @return \Drupal\workflow\Entity\WorkflowState
   *   A WorkflowState object.
   */
  public function getState($sid);

  /**
   * Creates a Transition for this workflow.
   *
   * @param string $from_sid
   * @param string $to_sid
   * @param array $values
   *
   * @return \Drupal\workflow\Entity\WorkflowConfigTransitionInterface
   */
  public function createTransition($from_sid, $to_sid, array $values = []);

  /**
   * Sorts all Transitions for this workflow, according to State weight.
   *
   * This is only needed for the Admin UI.
   */
  public function sortTransitions();

  /**
   * Loads all allowed ConfigTransitions for this workflow.
   *
   * @param array|null $ids
   *   Array of Transitions IDs. If NULL, show all transitions.
   * @param array $conditions
   *   $conditions['from_sid'] : if provided, a 'from' State ID.
   *   $conditions['to_sid'] : if provided, a 'to' state ID.
   *
   * @return \Drupal\workflow\Entity\WorkflowConfigTransition[]
   */
  public function getTransitions(array $ids = NULL, array $conditions = []);
  public function getTransitionsById($tid);

  /**
   * Get a specific transition.
   *
   * @param string $from_sid
   * @param string $to_sid
   *
   * @return \Drupal\workflow\Entity\WorkflowConfigTransition[]
   */
  public function getTransitionsByStateId($from_sid, $to_sid);

  /*
   * The following are copied from PluginSettingsInterface.php.
   */

  /**
   * Defines the default settings for this plugin.
   *
   * @return array
   *   A list of default settings, keyed by the setting name.
   */
  public static function defaultSettings();

  /**
   * Returns the array of settings, including defaults for missing settings.
   *
   * @return array
   *   The array of settings.
   */
  public function getSettings();

  /**
   * Returns the value of a setting, or its default value if absent.
   *
   * @param string $key
   *   The setting name.
   *
   * @return mixed
   *   The setting value.
   */
  public function getSetting($key);

  /**
   * Sets the settings for the plugin.
   *
   * @param array $settings
   *   The array of settings, keyed by setting names. Missing settings will be
   *   assigned their default values.
   *
   * @return $this
   */
  public function setSettings(array $settings);

  /**
   * Sets the value of a setting for the plugin.
   *
   * @param string $key
   *   The setting name.
   * @param mixed $value
   *   The setting value.
   *
   * @return $this
   */
  public function setSetting($key, $value);

}

Members

Namesort descending Modifiers Type Description Overrides
WorkflowInterface::createState public function Create a new state for this workflow. 1
WorkflowInterface::createTransition public function Creates a Transition for this workflow. 1
WorkflowInterface::defaultSettings public static function Defines the default settings for this plugin. 1
WorkflowInterface::getCreationSid public function Gets the ID of the initial state for a newly created entity. 1
WorkflowInterface::getCreationState public function Gets the initial state for a newly created entity. 1
WorkflowInterface::getFirstSid public function Gets the first valid state ID, after the creation state. 1
WorkflowInterface::getNextSid public function Returns the next state for the current state. 1
WorkflowInterface::getSetting public function Returns the value of a setting, or its default value if absent. 1
WorkflowInterface::getSettings public function Returns the array of settings, including defaults for missing settings. 1
WorkflowInterface::getState public function Gets a state for a given workflow. 1
WorkflowInterface::getStates public function Gets all states for a given workflow. 1
WorkflowInterface::getTransitions public function Loads all allowed ConfigTransitions for this workflow. 1
WorkflowInterface::getTransitionsById public function 1
WorkflowInterface::getTransitionsByStateId public function Get a specific transition. 1
WorkflowInterface::getWorkflowId public function Returns the workflow id. 1
WorkflowInterface::isDeletable public function Returns if the Workflow may be deleted. 1
WorkflowInterface::isValid public function Validate the workflow. Generate a message if not correct. 1
WorkflowInterface::setSetting public function Sets the value of a setting for the plugin. 1
WorkflowInterface::setSettings public function Sets the settings for the plugin. 1
WorkflowInterface::sortTransitions public function Sorts all Transitions for this workflow, according to State weight. 1