3 namespace Drupal\workflow_type_test\Plugin\WorkflowType;
5 use Drupal\workflows\Plugin\WorkflowTypeBase;
6 use Drupal\workflows\State;
12 * id = "predefined_states_workflow_test_type",
13 * label = @Translation("Predefined States Workflow Test Type"),
22 class PredefinedStatesWorkflowTestType extends WorkflowTypeBase {
27 public function getStates($state_ids = NULL) {
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;
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.'");
46 return $states[$state_id];
52 public function hasState($state_id) {
53 $states = $this->getStates();
54 return isset($states[$state_id]);
60 public function addState($state_id, $label) {
61 // States cannot be added on this workflow.
68 public function setStateLabel($state_id, $label) {
69 // States cannot be altered on this workflow.
76 public function setStateWeight($state_id, $weight) {
77 // States cannot be altered on this workflow.
84 public function deleteState($state_id) {
85 // States cannot be deleted on this workflow.
92 public function defaultConfiguration() {