PredefinedStatesWorkflowTestType.php in Drupal 10
File
core/modules/workflows/tests/modules/workflow_type_test/src/Plugin/WorkflowType/PredefinedStatesWorkflowTestType.php
View source
<?php
namespace Drupal\workflow_type_test\Plugin\WorkflowType;
use Drupal\workflows\Plugin\WorkflowTypeBase;
use Drupal\workflows\State;
class PredefinedStatesWorkflowTestType extends WorkflowTypeBase {
public function getStates($state_ids = NULL) {
return array_filter([
'pay_blinds' => new State($this, 'pay_blinds', 'Pay Blinds'),
'bet' => new State($this, 'bet', 'Bet'),
'raise' => new State($this, 'raise', 'Raise'),
'fold' => new State($this, 'fold', 'Fold'),
], function ($state) use ($state_ids) {
return is_array($state_ids) ? in_array($state
->id(), $state_ids) : TRUE;
});
}
public function getState($state_id) {
$states = $this
->getStates();
if (!isset($states[$state_id])) {
throw new \InvalidArgumentException("The state '{$state_id}' does not exist in workflow.'");
}
return $states[$state_id];
}
public function hasState($state_id) {
$states = $this
->getStates();
return isset($states[$state_id]);
}
public function addState($state_id, $label) {
return $this;
}
public function setStateLabel($state_id, $label) {
return $this;
}
public function setStateWeight($state_id, $weight) {
return $this;
}
public function deleteState($state_id) {
return $this;
}
public function defaultConfiguration() {
return [
'transitions' => [],
];
}
}