3 namespace Drupal\workflows;
5 use Drupal\Component\Plugin\ConfigurablePluginInterface;
6 use Drupal\Component\Plugin\DerivativeInspectionInterface;
7 use Drupal\Component\Plugin\PluginInspectionInterface;
8 use Drupal\Core\Form\FormStateInterface;
9 use Drupal\Core\Session\AccountInterface;
12 * An interface for Workflow type plugins.
15 * The workflow system is currently experimental and should only be leveraged
16 * by experimental modules and development releases of contributed modules.
18 interface WorkflowTypeInterface extends PluginInspectionInterface, DerivativeInspectionInterface, ConfigurablePluginInterface {
21 * Initializes a workflow.
23 * Used to create required states and default transitions.
25 * @param \Drupal\workflows\WorkflowInterface $workflow
26 * The workflow to initialize.
28 * @return \Drupal\workflows\WorkflowInterface
29 * The initialized workflow.
31 * @see \Drupal\workflows\Form\WorkflowAddForm::save()
33 public function initializeWorkflow(WorkflowInterface $workflow);
36 * Gets the label for the workflow type.
39 * The workflow type label.
41 public function label();
44 * Performs access checks.
46 * @param \Drupal\workflows\WorkflowInterface $entity
47 * The workflow entity for which to check access.
48 * @param string $operation
49 * The entity operation. Usually one of 'view', 'view label', 'update' or
51 * @param \Drupal\Core\Session\AccountInterface $account
52 * The user for which to check access.
54 * @return \Drupal\Core\Access\AccessResultInterface
57 public function checkWorkflowAccess(WorkflowInterface $entity, $operation, AccountInterface $account);
60 * Decorates states so the WorkflowType can add additional information.
62 * @param \Drupal\workflows\StateInterface $state
63 * The state object to decorate.
65 * @return \Drupal\workflows\StateInterface
66 * The decorated state object.
68 public function decorateState(StateInterface $state);
71 * React to the removal of a state from a workflow.
73 * @param string $state_id
74 * The state ID of the state that is being removed.
76 public function deleteState($state_id);
79 * Decorates transitions so the WorkflowType can add additional information.
80 * @param \Drupal\workflows\TransitionInterface $transition
81 * The transition object to decorate.
83 * @return \Drupal\workflows\TransitionInterface
84 * The decorated transition object.
86 public function decorateTransition(TransitionInterface $transition);
89 * React to the removal of a transition from a workflow.
91 * @param string $transition_id
92 * The transition ID of the transition that is being removed.
94 public function deleteTransition($transition_id);
97 * Gets the initial state for the workflow.
99 * @param \Drupal\workflows\WorkflowInterface $workflow
100 * The workflow entity.
102 * @return \Drupal\workflows\StateInterface
105 public function getInitialState(WorkflowInterface $workflow);
108 * Builds a form to be added to the Workflow state edit form.
110 * @param \Drupal\Core\Form\FormStateInterface $form_state
112 * @param \Drupal\workflows\WorkflowInterface $workflow
113 * The workflow the state is attached to.
114 * @param \Drupal\workflows\StateInterface|null $state
115 * The workflow state being edited. If NULL, a new state is being added.
118 * Form elements to add to a workflow state form for customisations to the
121 * @see \Drupal\workflows\Form\WorkflowStateAddForm::form()
122 * @see \Drupal\workflows\Form\WorkflowStateEditForm::form()
124 public function buildStateConfigurationForm(FormStateInterface $form_state, WorkflowInterface $workflow, StateInterface $state = NULL);
127 * Builds a form to be added to the Workflow transition edit form.
129 * @param \Drupal\Core\Form\FormStateInterface $form_state
131 * @param \Drupal\workflows\WorkflowInterface $workflow
132 * The workflow the state is attached to.
133 * @param \Drupal\workflows\TransitionInterface|null $transition
134 * The workflow transition being edited. If NULL, a new transition is being
138 * Form elements to add to a workflow transition form for customisations to
141 * @see \Drupal\workflows\Form\WorkflowTransitionAddForm::form()
142 * @see \Drupal\workflows\Form\WorkflowTransitionEditForm::form()
144 public function buildTransitionConfigurationForm(FormStateInterface $form_state, WorkflowInterface $workflow, TransitionInterface $transition = NULL);
147 * Gets the required states of workflow type.
149 * This are usually configured in the workflow type annotation.
152 * The required states.
154 * @see \Drupal\workflows\Annotation\WorkflowType
156 public function getRequiredStates();
159 * Informs the plugin that a dependency of the workflow will be deleted.
161 * @param array $dependencies
162 * An array of dependencies that will be deleted keyed by dependency type.
165 * TRUE if the workflow settings have been changed, FALSE if not.
167 * @see \Drupal\Core\Config\ConfigEntityInterface::onDependencyRemoval()
169 * @todo https://www.drupal.org/node/2579743 make part of a generic interface.
171 public function onDependencyRemoval(array $dependencies);