Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / workflows / tests / modules / workflow_type_test / src / Plugin / WorkflowType / PredefinedStatesWorkflowTestType.php
1 <?php
2
3 namespace Drupal\workflow_type_test\Plugin\WorkflowType;
4
5 use Drupal\workflows\Plugin\WorkflowTypeBase;
6 use Drupal\workflows\State;
7
8 /**
9  * Test workflow type.
10  *
11  * @WorkflowType(
12  *   id = "predefined_states_workflow_test_type",
13  *   label = @Translation("Predefined States Workflow Test Type"),
14  *   required_states = {
15  *     "pay_blinds",
16  *     "bet",
17  *     "raise",
18  *     "fold",
19  *   }
20  * )
21  */
22 class PredefinedStatesWorkflowTestType extends WorkflowTypeBase {
23
24   /**
25    * {@inheritdoc}
26    */
27   public function getStates($state_ids = NULL) {
28     return array_filter([
29       'pay_blinds' => new State($this, 'pay_blinds', 'Pay Blinds'),
30       'bet' => new State($this, 'bet', 'Bet'),
31       'raise' => new State($this, 'raise', 'Raise'),
32       'fold' => new State($this, 'fold', 'Fold'),
33     ], function ($state) use ($state_ids) {
34         return is_array($state_ids) ? in_array($state->id(), $state_ids) : TRUE;
35     });
36   }
37
38   /**
39    * {@inheritdoc}
40    */
41   public function getState($state_id) {
42     $states = $this->getStates();
43     if (!isset($states[$state_id])) {
44       throw new \InvalidArgumentException("The state '$state_id' does not exist in workflow.'");
45     }
46     return $states[$state_id];
47   }
48
49   /**
50    * {@inheritdoc}
51    */
52   public function hasState($state_id) {
53     $states = $this->getStates();
54     return isset($states[$state_id]);
55   }
56
57   /**
58    * {@inheritdoc}
59    */
60   public function addState($state_id, $label) {
61     // States cannot be added on this workflow.
62     return $this;
63   }
64
65   /**
66    * {@inheritdoc}
67    */
68   public function setStateLabel($state_id, $label) {
69     // States cannot be altered on this workflow.
70     return $this;
71   }
72
73   /**
74    * {@inheritdoc}
75    */
76   public function setStateWeight($state_id, $weight) {
77     // States cannot be altered on this workflow.
78     return $this;
79   }
80
81   /**
82    * {@inheritdoc}
83    */
84   public function deleteState($state_id) {
85     // States cannot be deleted on this workflow.
86     return $this;
87   }
88
89   /**
90    * {@inheritdoc}
91    */
92   public function defaultConfiguration() {
93     return [
94       'transitions' => [],
95     ];
96   }
97
98 }