interface WorkflowTypeInterface

Same name and namespace in other branches
  1. 9 core/modules/workflows/src/WorkflowTypeInterface.php \Drupal\workflows\WorkflowTypeInterface
  2. 8.9.x core/modules/workflows/src/WorkflowTypeInterface.php \Drupal\workflows\WorkflowTypeInterface
  3. 10 core/modules/workflows/src/WorkflowTypeInterface.php \Drupal\workflows\WorkflowTypeInterface

An interface for Workflow type plugins.

Hierarchy

Expanded class hierarchy of WorkflowTypeInterface

All classes that implement WorkflowTypeInterface

5 files declare their use of WorkflowTypeInterface
ContentModerationInterface.php in core/modules/content_moderation/src/Plugin/WorkflowType/ContentModerationInterface.php
StateTest.php in core/modules/workflows/tests/src/Unit/StateTest.php
TransitionTest.php in core/modules/workflows/tests/src/Unit/TransitionTest.php
WorkflowEditForm.php in core/modules/workflows/src/Form/WorkflowEditForm.php
WorkflowTypeBase.php in core/modules/workflows/src/Plugin/WorkflowTypeBase.php
1 string reference to 'WorkflowTypeInterface'
workflows.schema.yml in core/modules/workflows/config/schema/workflows.schema.yml
core/modules/workflows/config/schema/workflows.schema.yml

File

core/modules/workflows/src/WorkflowTypeInterface.php, line 13

Namespace

Drupal\workflows
View source
interface WorkflowTypeInterface extends PluginWithFormsInterface, DerivativeInspectionInterface, ConfigurableInterface, DependentPluginInterface {
    
    /**
     * The key of the global workflow plugin form.
     */
    const PLUGIN_FORM_KEY = 'configure';
    
    /**
     * Gets the label for the workflow type.
     *
     * @return string
     *   The workflow type label.
     */
    public function label();
    
    /**
     * Determines if the workflow is being has data associated with it.
     *
     * @internal
     *   Marked as internal until it's validated this should form part of the
     *   public API in https://www.drupal.org/node/2897148.
     *
     * @param \Drupal\workflows\WorkflowInterface $workflow
     *   The workflow to check.
     *
     * @return bool
     *   TRUE if the workflow is being used, FALSE if not.
     */
    public function workflowHasData(WorkflowInterface $workflow);
    
    /**
     * Determines if the workflow state has data associated with it.
     *
     * @internal
     *   Marked as internal until it's validated this should form part of the
     *   public API in https://www.drupal.org/node/2897148.
     *
     * @param \Drupal\workflows\WorkflowInterface $workflow
     *   The workflow to check.
     * @param \Drupal\workflows\StateInterface $state
     *   The workflow state to check.
     *
     * @return bool
     *   TRUE if the workflow state is being used, FALSE if not.
     */
    public function workflowStateHasData(WorkflowInterface $workflow, StateInterface $state);
    
    /**
     * Gets the initial state for the workflow.
     *
     * @return \Drupal\workflows\StateInterface
     *   The initial state.
     */
    public function getInitialState();
    
    /**
     * Gets the required states of workflow type.
     *
     * This is usually specified in the workflow type annotation.
     *
     * @return string[]
     *   The required states.
     *
     * @see \Drupal\workflows\Annotation\WorkflowType
     */
    public function getRequiredStates();
    
    /**
     * Informs the plugin that a dependency of the workflow will be deleted.
     *
     * @param array $dependencies
     *   An array of dependencies that will be deleted keyed by dependency type.
     *
     * @return bool
     *   TRUE if the workflow settings have been changed, FALSE if not.
     *
     * @see \Drupal\Core\Config\ConfigEntityInterface::onDependencyRemoval()
     *
     * @todo https://www.drupal.org/node/2579743 make part of a generic interface.
     */
    public function onDependencyRemoval(array $dependencies);
    
    /**
     * Adds a state to the workflow.
     *
     * @param string $state_id
     *   The state's ID.
     * @param string $label
     *   The state's label.
     *
     * @return $this
     *
     * @throws \InvalidArgumentException
     *   Thrown if a state already exists or state ID is invalid.
     */
    public function addState($state_id, $label);
    
    /**
     * Determines if the workflow has a state with the provided ID.
     *
     * @param string $state_id
     *   The state's ID.
     *
     * @return bool
     *   TRUE if the workflow has a state with the provided ID, FALSE if not.
     */
    public function hasState($state_id);
    
    /**
     * Gets state objects for the provided state IDs.
     *
     * @param string[] $state_ids
     *   A list of state IDs to get. If NULL then all states will be returned.
     *
     * @return \Drupal\workflows\StateInterface[]
     *   An array of workflow states, keyed by state IDs.
     *
     * @throws \InvalidArgumentException
     *   Thrown if $state_ids contains a state ID that does not exist.
     */
    public function getStates($state_ids = NULL);
    
    /**
     * Gets a workflow state.
     *
     * @param string $state_id
     *   The state's ID.
     *
     * @return \Drupal\workflows\StateInterface
     *   The workflow state.
     *
     * @throws \InvalidArgumentException
     *   Thrown if $state_id does not exist.
     */
    public function getState($state_id);
    
    /**
     * Sets a state's label.
     *
     * @param string $state_id
     *   The state ID to set the label for.
     * @param string $label
     *   The state's label.
     *
     * @return $this
     */
    public function setStateLabel($state_id, $label);
    
    /**
     * Sets a state's weight value.
     *
     * @param string $state_id
     *   The state ID to set the weight for.
     * @param int $weight
     *   The state's weight.
     *
     * @return $this
     */
    public function setStateWeight($state_id, $weight);
    
    /**
     * Deletes a state from the workflow.
     *
     * @param string $state_id
     *   The state ID to delete.
     *
     * @return $this
     *   The workflow type plugin.
     *
     * @throws \InvalidArgumentException
     *   Thrown if $state_id does not exist.
     */
    public function deleteState($state_id);
    
    /**
     * Adds a transition to the workflow.
     *
     * @param string $id
     *   The transition ID.
     * @param string $label
     *   The transition's label.
     * @param array $from_state_ids
     *   The state IDs to transition from.
     * @param string $to_state_id
     *   The state ID to transition to.
     *
     * @return $this
     *
     * @throws \InvalidArgumentException
     *   Thrown if either state does not exist.
     */
    public function addTransition($id, $label, array $from_state_ids, $to_state_id);
    
    /**
     * Gets a transition object for the provided transition ID.
     *
     * @param string $transition_id
     *   A transition ID.
     *
     * @return \Drupal\workflows\TransitionInterface
     *   The transition.
     *
     * @throws \InvalidArgumentException
     *   Thrown if $transition_id does not exist.
     */
    public function getTransition($transition_id);
    
    /**
     * Determines if a transition exists.
     *
     * @param string $transition_id
     *   The transition ID.
     *
     * @return bool
     *   TRUE if the transition exists, FALSE if not.
     */
    public function hasTransition($transition_id);
    
    /**
     * Gets transition objects for the provided transition IDs.
     *
     * @param string[] $transition_ids
     *   A list of transition IDs to get. If NULL then all transitions will be
     *   returned.
     *
     * @return \Drupal\workflows\TransitionInterface[]
     *   An array of transition objects.
     *
     * @throws \InvalidArgumentException
     *   Thrown if $transition_ids contains a transition ID that does not exist.
     */
    public function getTransitions(?array $transition_ids = NULL);
    
    /**
     * Gets the transitions for a state for the provided direction.
     *
     * @param $state_id
     *   The state to get transitions for.
     * @param string $direction
     *   (optional) The direction of the transition, defaults to
     *   TransitionInterface::DIRECTION_FROM. Possible values are:
     *   TransitionInterface::DIRECTION_FROM or TransitionInterface::DIRECTION_TO.
     *
     * @return \Drupal\workflows\TransitionInterface[]
     *   An array of the transition objects for the state in the given direction,
     *   keyed by transition ID.
     *
     * @see \Drupal\workflows\TransitionInterface::DIRECTION_FROM
     * @see \Drupal\workflows\TransitionInterface::DIRECTION_TO
     */
    public function getTransitionsForState($state_id, $direction = TransitionInterface::DIRECTION_FROM);
    
    /**
     * Gets a transition from state to state.
     *
     * @param string $from_state_id
     *   The state ID to transition from.
     * @param string $to_state_id
     *   The state ID to transition to.
     *
     * @return \Drupal\workflows\TransitionInterface
     *   The transitions.
     *
     * @throws \InvalidArgumentException
     *   Thrown if the transition does not exist.
     */
    public function getTransitionFromStateToState($from_state_id, $to_state_id);
    
    /**
     * Determines if a transition from state to state exists.
     *
     * @param string $from_state_id
     *   The state ID to transition from.
     * @param string $to_state_id
     *   The state ID to transition to.
     *
     * @return bool
     *   TRUE if the transition exists, FALSE if not.
     */
    public function hasTransitionFromStateToState($from_state_id, $to_state_id);
    
    /**
     * Sets a transition's label.
     *
     * @param string $transition_id
     *   The transition ID.
     * @param string $label
     *   The transition's label.
     *
     * @return $this
     *
     * @throws \InvalidArgumentException
     *   Thrown if the transition does not exist.
     */
    public function setTransitionLabel($transition_id, $label);
    
    /**
     * Sets a transition's weight.
     *
     * @param string $transition_id
     *   The transition ID.
     * @param int $weight
     *   The transition's weight.
     *
     * @return $this
     *
     * @throws \InvalidArgumentException
     *   Thrown if the transition does not exist.
     */
    public function setTransitionWeight($transition_id, $weight);
    
    /**
     * Sets a transition's from states.
     *
     * @param string $transition_id
     *   The transition ID.
     * @param array $from_state_ids
     *   The state IDs to transition from.
     *
     * @return $this
     *
     * @throws \InvalidArgumentException
     *   Thrown if the transition does not exist or the states do not exist.
     */
    public function setTransitionFromStates($transition_id, array $from_state_ids);
    
    /**
     * Deletes a transition.
     *
     * @param string $transition_id
     *   The transition ID.
     *
     * @return $this
     *
     * @throws \InvalidArgumentException
     *   Thrown if the transition does not exist.
     */
    public function deleteTransition($transition_id);

}

Members

Title Sort descending Modifiers Object type Summary Overrides
ConfigurableInterface::defaultConfiguration public function Gets default configuration for this plugin. 13
ConfigurableInterface::getConfiguration public function Gets this plugin's configuration. 13
ConfigurableInterface::setConfiguration public function Sets the configuration for this plugin instance. 13
DependentPluginInterface::calculateDependencies public function Calculates dependencies for the configured plugin. 19
DerivativeInspectionInterface::getBaseId public function Gets the base_plugin_id of the plugin instance. 1
DerivativeInspectionInterface::getDerivativeId public function Gets the derivative_id of the plugin instance. 1
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 6
PluginInspectionInterface::getPluginId public function Gets the plugin_id of the plugin instance. 2
PluginWithFormsInterface::getFormClass public function Gets the form class for the given operation.
PluginWithFormsInterface::hasFormClass public function Gets whether the plugin has a form class for the given operation.
WorkflowTypeInterface::addState public function Adds a state to the workflow. 1
WorkflowTypeInterface::addTransition public function Adds a transition to the workflow. 1
WorkflowTypeInterface::deleteState public function Deletes a state from the workflow. 1
WorkflowTypeInterface::deleteTransition public function Deletes a transition. 1
WorkflowTypeInterface::getInitialState public function Gets the initial state for the workflow. 2
WorkflowTypeInterface::getRequiredStates public function Gets the required states of workflow type. 1
WorkflowTypeInterface::getState public function Gets a workflow state. 1
WorkflowTypeInterface::getStates public function Gets state objects for the provided state IDs. 1
WorkflowTypeInterface::getTransition public function Gets a transition object for the provided transition ID. 1
WorkflowTypeInterface::getTransitionFromStateToState public function Gets a transition from state to state. 1
WorkflowTypeInterface::getTransitions public function Gets transition objects for the provided transition IDs. 1
WorkflowTypeInterface::getTransitionsForState public function Gets the transitions for a state for the provided direction. 1
WorkflowTypeInterface::hasState public function Determines if the workflow has a state with the provided ID. 1
WorkflowTypeInterface::hasTransition public function Determines if a transition exists. 1
WorkflowTypeInterface::hasTransitionFromStateToState public function Determines if a transition from state to state exists. 1
WorkflowTypeInterface::label public function Gets the label for the workflow type. 1
WorkflowTypeInterface::onDependencyRemoval public function Informs the plugin that a dependency of the workflow will be deleted. 1
WorkflowTypeInterface::PLUGIN_FORM_KEY constant The key of the global workflow plugin form.
WorkflowTypeInterface::setStateLabel public function Sets a state's label. 1
WorkflowTypeInterface::setStateWeight public function Sets a state's weight value. 1
WorkflowTypeInterface::setTransitionFromStates public function Sets a transition's from states. 1
WorkflowTypeInterface::setTransitionLabel public function Sets a transition's label. 1
WorkflowTypeInterface::setTransitionWeight public function Sets a transition's weight. 1
WorkflowTypeInterface::workflowHasData public function Determines if the workflow is being has data associated with it. 1
WorkflowTypeInterface::workflowStateHasData public function Determines if the workflow state has data associated with it. 1

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.