interface WorkflowTypeInterface implements PluginWithFormsInterface, DerivativeInspectionInterface, ConfigurableInterface, DependentPluginInterface (View source)

An interface for Workflow type plugins.

Constants

PLUGIN_FORM_KEY

The key of the global workflow plugin form.

Methods

string
getPluginId()

Gets the plugin_id of the plugin instance.

array
getPluginDefinition()

Gets the definition of the plugin implementation.

string|null
getFormClass(string $operation)

Gets the form class for the given operation.

bool
hasFormClass(string $operation)

Gets whether the plugin has a form class for the given operation.

string
getBaseId()

Gets the base_plugin_id of the plugin instance.

string|null
getDerivativeId()

Gets the derivative_id of the plugin instance.

array
getConfiguration()

Gets this plugin's configuration.

setConfiguration(array $configuration)

Sets the configuration for this plugin instance.

array
defaultConfiguration()

Gets default configuration for this plugin.

array
calculateDependencies()

Calculates dependencies for the configured plugin.

string
label()

Gets the label for the workflow type.

bool
workflowHasData(WorkflowInterface $workflow)

Determines if the workflow is being has data associated with it.

bool
workflowStateHasData(WorkflowInterface $workflow, StateInterface $state)

Determines if the workflow state has data associated with it.

getInitialState()

Gets the initial state for the workflow.

string[]
getRequiredStates()

Gets the required states of workflow type.

bool
onDependencyRemoval(array $dependencies)

Informs the plugin that a dependency of the workflow will be deleted.

$this
addState(string $state_id, string $label)

Adds a state to the workflow.

bool
hasState(string $state_id)

Determines if the workflow has a state with the provided ID.

getStates(string[] $state_ids = NULL)

Gets state objects for the provided state IDs.

getState(string $state_id)

Gets a workflow state.

$this
setStateLabel(string $state_id, string $label)

Sets a state's label.

$this
setStateWeight(string $state_id, int $weight)

Sets a state's weight value.

$this
deleteState(string $state_id)

Deletes a state from the workflow.

$this
addTransition(string $id, string $label, array $from_state_ids, string $to_state_id)

Adds a transition to the workflow.

getTransition(string $transition_id)

Gets a transition object for the provided transition ID.

bool
hasTransition(string $transition_id)

Determines if a transition exists.

getTransitions(array $transition_ids = NULL)

Gets transition objects for the provided transition IDs.

array
getTransitionsForState($state_id, string $direction = TransitionInterface::DIRECTION_FROM)

Gets the transition IDs for a state for the provided direction.

getTransitionFromStateToState(string $from_state_id, string $to_state_id)

Gets a transition from state to state.

bool
hasTransitionFromStateToState(string $from_state_id, string $to_state_id)

Determines if a transition from state to state exists.

$this
setTransitionLabel(string $transition_id, string $label)

Sets a transition's label.

$this
setTransitionWeight(string $transition_id, int $weight)

Sets a transition's weight.

$this
setTransitionFromStates(string $transition_id, array $from_state_ids)

Sets a transition's from states.

$this
deleteTransition(string $transition_id)

Deletes a transition.

Details

string getPluginId()

Gets the plugin_id of the plugin instance.

Return Value

string

The plugin_id of the plugin instance.

array getPluginDefinition()

Gets the definition of the plugin implementation.

Return Value

array

The plugin definition, as returned by the discovery object used by the plugin manager.

string|null getFormClass(string $operation)

Gets the form class for the given operation.

Parameters

string $operation

The name of the operation.

Return Value

string|null

The form class if defined, NULL otherwise.

bool hasFormClass(string $operation)

Gets whether the plugin has a form class for the given operation.

Parameters

string $operation

The name of the operation.

Return Value

bool

TRUE if the plugin has a form class for the given operation.

string getBaseId()

Gets the base_plugin_id of the plugin instance.

Return Value

string

The base_plugin_id of the plugin instance.

string|null getDerivativeId()

Gets the derivative_id of the plugin instance.

Return Value

string|null

The derivative_id of the plugin instance NULL otherwise.

array getConfiguration()

Gets this plugin's configuration.

Return Value

array

An array of this plugin's configuration.

setConfiguration(array $configuration)

Sets the configuration for this plugin instance.

Parameters

array $configuration

An associative array containing the plugin's configuration.

array defaultConfiguration()

Gets default configuration for this plugin.

Return Value

array

An associative array with the default configuration.

array calculateDependencies()

Calculates dependencies for the configured plugin.

Dependencies are saved in the plugin's configuration entity and are used to determine configuration synchronization order. For example, if the plugin integrates with specific user roles, this method should return an array of dependencies listing the specified roles.

Return Value

array

An array of dependencies grouped by type (config, content, module, theme). For example: @code array( 'config' => array('user.role.anonymous', 'user.role.authenticated'), 'content' => array('node:article:f0a189e6-55fb-47fb-8005-5bef81c44d6d'), 'module' => array('node', 'user'), 'theme' => array('seven'), ); @endcode

See also

ConfigDependencyManager
EntityInterface::getConfigDependencyName

string label()

Gets the label for the workflow type.

Return Value

string

The workflow type label.

bool workflowHasData(WorkflowInterface $workflow)

internal  Marked as internal until it's validated this should form part of the public API in https://www.drupal.org/node/2897148.
 

Determines if the workflow is being has data associated with it.

Parameters

WorkflowInterface $workflow

The workflow to check.

Return Value

bool

TRUE if the workflow is being used, FALSE if not.

bool workflowStateHasData(WorkflowInterface $workflow, StateInterface $state)

internal  Marked as internal until it's validated this should form part of the public API in https://www.drupal.org/node/2897148.
 

Determines if the workflow state has data associated with it.

Parameters

WorkflowInterface $workflow

The workflow to check.

StateInterface $state

The workflow state to check.

Return Value

bool

TRUE if the workflow state is being used, FALSE if not.

StateInterface getInitialState()

Gets the initial state for the workflow.

Return Value

StateInterface

The initial state.

string[] getRequiredStates()

Gets the required states of workflow type.

This is usually specified in the workflow type annotation.

Return Value

string[]

The required states.

See also

WorkflowType

bool onDependencyRemoval(array $dependencies)

Informs the plugin that a dependency of the workflow will be deleted.

https://www.drupal.org/node/2579743 make part of a generic interface.

Parameters

array $dependencies

An array of dependencies that will be deleted keyed by dependency type.

Return Value

bool

TRUE if the workflow settings have been changed, FALSE if not.

See also

\Drupal\Core\Config\ConfigEntityInterface::onDependencyRemoval()

$this addState(string $state_id, string $label)

Adds a state to the workflow.

Parameters

string $state_id

The state's ID.

string $label

The state's label.

Return Value

$this

Exceptions

InvalidArgumentException

bool hasState(string $state_id)

Determines if the workflow has a state with the provided ID.

Parameters

string $state_id

The state's ID.

Return Value

bool

TRUE if the workflow has a state with the provided ID, FALSE if not.

StateInterface[] getStates(string[] $state_ids = NULL)

Gets state objects for the provided state IDs.

Parameters

string[] $state_ids

A list of state IDs to get. If NULL then all states will be returned.

Return Value

StateInterface[]

An array of workflow states, keyed by state IDs.

Exceptions

InvalidArgumentException

StateInterface getState(string $state_id)

Gets a workflow state.

Parameters

string $state_id

The state's ID.

Return Value

StateInterface

The workflow state.

Exceptions

InvalidArgumentException

$this setStateLabel(string $state_id, string $label)

Sets a state's label.

Parameters

string $state_id

The state ID to set the label for.

string $label

The state's label.

Return Value

$this

$this setStateWeight(string $state_id, int $weight)

Sets a state's weight value.

Parameters

string $state_id

The state ID to set the weight for.

int $weight

The state's weight.

Return Value

$this

$this deleteState(string $state_id)

Deletes a state from the workflow.

Parameters

string $state_id

The state ID to delete.

Return Value

$this

The workflow type plugin.

Exceptions

InvalidArgumentException

$this addTransition(string $id, string $label, array $from_state_ids, string $to_state_id)

Adds a transition to the workflow.

Parameters

string $id

The transition ID.

string $label

The transition's label.

array $from_state_ids

The state IDs to transition from.

string $to_state_id

The state ID to transition to.

Return Value

$this

Exceptions

InvalidArgumentException

TransitionInterface getTransition(string $transition_id)

Gets a transition object for the provided transition ID.

Parameters

string $transition_id

A transition ID.

Return Value

TransitionInterface

The transition.

Exceptions

InvalidArgumentException

bool hasTransition(string $transition_id)

Determines if a transition exists.

Parameters

string $transition_id

The transition ID.

Return Value

bool

TRUE if the transition exists, FALSE if not.

TransitionInterface[] getTransitions(array $transition_ids = NULL)

Gets transition objects for the provided transition IDs.

Parameters

array $transition_ids

A list of transition IDs to get. If NULL then all transitions will be returned.

Return Value

TransitionInterface[]

An array of transition objects.

Exceptions

InvalidArgumentException

array getTransitionsForState($state_id, string $direction = TransitionInterface::DIRECTION_FROM)

Gets the transition IDs for a state for the provided direction.

Parameters

$state_id

The state to get transitions for.

string $direction

(optional) The direction of the transition, defaults to TransitionInterface::DIRECTION_FROM. Possible values are: TransitionInterface::DIRECTION_FROM or TransitionInterface::DIRECTION_TO.

Return Value

array

The transition IDs for a state for the provided direction.

See also

TransitionInterface::DIRECTION_FROM
TransitionInterface::DIRECTION_TO

TransitionInterface getTransitionFromStateToState(string $from_state_id, string $to_state_id)

Gets a transition from state to state.

Parameters

string $from_state_id

The state ID to transition from.

string $to_state_id

The state ID to transition to.

Return Value

TransitionInterface

The transitions.

Exceptions

InvalidArgumentException

bool hasTransitionFromStateToState(string $from_state_id, string $to_state_id)

Determines if a transition from state to state exists.

Parameters

string $from_state_id

The state ID to transition from.

string $to_state_id

The state ID to transition to.

Return Value

bool

TRUE if the transition exists, FALSE if not.

$this setTransitionLabel(string $transition_id, string $label)

Sets a transition's label.

Parameters

string $transition_id

The transition ID.

string $label

The transition's label.

Return Value

$this

Exceptions

InvalidArgumentException

$this setTransitionWeight(string $transition_id, int $weight)

Sets a transition's weight.

Parameters

string $transition_id

The transition ID.

int $weight

The transition's weight.

Return Value

$this

Exceptions

InvalidArgumentException

$this setTransitionFromStates(string $transition_id, array $from_state_ids)

Sets a transition's from states.

Parameters

string $transition_id

The transition ID.

array $from_state_ids

The state IDs to transition from.

Return Value

$this

Exceptions

InvalidArgumentException

$this deleteTransition(string $transition_id)

Deletes a transition.

Parameters

string $transition_id

The transition ID.

Return Value

$this

Exceptions

InvalidArgumentException