Further changes for the Use cases on the live site.
[yaffs-website] / web / core / modules / workflows / src / WorkflowTypeInterface.php
1 <?php
2
3 namespace Drupal\workflows;
4
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;
10
11 /**
12  * An interface for Workflow type plugins.
13  *
14  * @internal
15  *   The workflow system is currently experimental and should only be leveraged
16  *   by experimental modules and development releases of contributed modules.
17  */
18 interface WorkflowTypeInterface extends PluginInspectionInterface, DerivativeInspectionInterface, ConfigurablePluginInterface {
19
20   /**
21    * Initializes a workflow.
22    *
23    * Used to create required states and default transitions.
24    *
25    * @param \Drupal\workflows\WorkflowInterface $workflow
26    *   The workflow to initialize.
27    *
28    * @return \Drupal\workflows\WorkflowInterface
29    *   The initialized workflow.
30    *
31    * @see \Drupal\workflows\Form\WorkflowAddForm::save()
32    */
33   public function initializeWorkflow(WorkflowInterface $workflow);
34
35   /**
36    * Gets the label for the workflow type.
37    *
38    * @return string
39    *   The workflow type label.
40    */
41   public function label();
42
43   /**
44    * Performs access checks.
45    *
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
50    *   'delete'.
51    * @param \Drupal\Core\Session\AccountInterface $account
52    *   The user for which to check access.
53    *
54    * @return \Drupal\Core\Access\AccessResultInterface
55    *   The access result.
56    */
57   public function checkWorkflowAccess(WorkflowInterface $entity, $operation, AccountInterface $account);
58
59   /**
60    * Decorates states so the WorkflowType can add additional information.
61    *
62    * @param \Drupal\workflows\StateInterface $state
63    *   The state object to decorate.
64    *
65    * @return \Drupal\workflows\StateInterface
66    *   The decorated state object.
67    */
68   public function decorateState(StateInterface $state);
69
70   /**
71    * React to the removal of a state from a workflow.
72    *
73    * @param string $state_id
74    *   The state ID of the state that is being removed.
75    */
76   public function deleteState($state_id);
77
78   /**
79    * Decorates transitions so the WorkflowType can add additional information.
80    * @param \Drupal\workflows\TransitionInterface $transition
81    *   The transition object to decorate.
82    *
83    * @return \Drupal\workflows\TransitionInterface
84    *   The decorated transition object.
85    */
86   public function decorateTransition(TransitionInterface $transition);
87
88   /**
89    * React to the removal of a transition from a workflow.
90    *
91    * @param string $transition_id
92    *   The transition ID of the transition that is being removed.
93    */
94   public function deleteTransition($transition_id);
95
96   /**
97    * Gets the initial state for the workflow.
98    *
99    * @param \Drupal\workflows\WorkflowInterface $workflow
100    *   The workflow entity.
101    *
102    * @return \Drupal\workflows\StateInterface
103    *   The initial state.
104    */
105   public function getInitialState(WorkflowInterface $workflow);
106
107   /**
108    * Builds a form to be added to the Workflow state edit form.
109    *
110    * @param \Drupal\Core\Form\FormStateInterface $form_state
111    *   The 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.
116    *
117    * @return array
118    *   Form elements to add to a workflow state form for customisations to the
119    *   workflow.
120    *
121    * @see \Drupal\workflows\Form\WorkflowStateAddForm::form()
122    * @see \Drupal\workflows\Form\WorkflowStateEditForm::form()
123    */
124   public function buildStateConfigurationForm(FormStateInterface $form_state, WorkflowInterface $workflow, StateInterface $state = NULL);
125
126   /**
127    * Builds a form to be added to the Workflow transition edit form.
128    *
129    * @param \Drupal\Core\Form\FormStateInterface $form_state
130    *   The 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
135    *   added.
136    *
137    * @return array
138    *   Form elements to add to a workflow transition form for customisations to
139    *   the workflow.
140    *
141    * @see \Drupal\workflows\Form\WorkflowTransitionAddForm::form()
142    * @see \Drupal\workflows\Form\WorkflowTransitionEditForm::form()
143    */
144   public function buildTransitionConfigurationForm(FormStateInterface $form_state, WorkflowInterface $workflow, TransitionInterface $transition = NULL);
145
146   /**
147    * Gets the required states of workflow type.
148    *
149    * This are usually configured in the workflow type annotation.
150    *
151    * @return array[]
152    *   The required states.
153    *
154    * @see \Drupal\workflows\Annotation\WorkflowType
155    */
156   public function getRequiredStates();
157
158   /**
159    * Informs the plugin that a dependency of the workflow will be deleted.
160    *
161    * @param array $dependencies
162    *   An array of dependencies that will be deleted keyed by dependency type.
163    *
164    * @return bool
165    *   TRUE if the workflow settings have been changed, FALSE if not.
166    *
167    * @see \Drupal\Core\Config\ConfigEntityInterface::onDependencyRemoval()
168    *
169    * @todo https://www.drupal.org/node/2579743 make part of a generic interface.
170    */
171   public function onDependencyRemoval(array $dependencies);
172
173 }