class PredefinedStatesWorkflowTestType
Same name in other branches
- 8.9.x core/modules/workflows/tests/modules/workflow_type_test/src/Plugin/WorkflowType/PredefinedStatesWorkflowTestType.php \Drupal\workflow_type_test\Plugin\WorkflowType\PredefinedStatesWorkflowTestType
- 10 core/modules/workflows/tests/modules/workflow_type_test/src/Plugin/WorkflowType/PredefinedStatesWorkflowTestType.php \Drupal\workflow_type_test\Plugin\WorkflowType\PredefinedStatesWorkflowTestType
- 11.x core/modules/workflows/tests/modules/workflow_type_test/src/Plugin/WorkflowType/PredefinedStatesWorkflowTestType.php \Drupal\workflow_type_test\Plugin\WorkflowType\PredefinedStatesWorkflowTestType
Test workflow type.
Plugin annotation
@WorkflowType(
id = "predefined_states_workflow_test_type",
label = @Translation("Predefined States Workflow Test Type"),
required_states = {
"pay_blinds",
"bet",
"raise",
"fold",
}
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\workflows\Plugin\WorkflowTypeBase extends \Drupal\Component\Plugin\PluginBase implements \Drupal\workflows\WorkflowTypeInterface uses \Drupal\Core\Plugin\PluginWithFormsTrait
- class \Drupal\workflow_type_test\Plugin\WorkflowType\PredefinedStatesWorkflowTestType extends \Drupal\workflows\Plugin\WorkflowTypeBase
- class \Drupal\workflows\Plugin\WorkflowTypeBase extends \Drupal\Component\Plugin\PluginBase implements \Drupal\workflows\WorkflowTypeInterface uses \Drupal\Core\Plugin\PluginWithFormsTrait
Expanded class hierarchy of PredefinedStatesWorkflowTestType
File
-
core/
modules/ workflows/ tests/ modules/ workflow_type_test/ src/ Plugin/ WorkflowType/ PredefinedStatesWorkflowTestType.php, line 22
Namespace
Drupal\workflow_type_test\Plugin\WorkflowTypeView source
class PredefinedStatesWorkflowTestType extends WorkflowTypeBase {
/**
* {@inheritdoc}
*/
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;
});
}
/**
* {@inheritdoc}
*/
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];
}
/**
* {@inheritdoc}
*/
public function hasState($state_id) {
$states = $this->getStates();
return isset($states[$state_id]);
}
/**
* {@inheritdoc}
*/
public function addState($state_id, $label) {
// States cannot be added on this workflow.
return $this;
}
/**
* {@inheritdoc}
*/
public function setStateLabel($state_id, $label) {
// States cannot be altered on this workflow.
return $this;
}
/**
* {@inheritdoc}
*/
public function setStateWeight($state_id, $weight) {
// States cannot be altered on this workflow.
return $this;
}
/**
* {@inheritdoc}
*/
public function deleteState($state_id) {
// States cannot be deleted on this workflow.
return $this;
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [
'transitions' => [],
];
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
PluginBase::$configuration | protected | property | Configuration information passed into the plugin. | ||
PluginBase::$pluginDefinition | protected | property | The plugin implementation definition. | ||
PluginBase::$pluginId | protected | property | The plugin_id. | ||
PluginBase::DERIVATIVE_SEPARATOR | constant | A string which is used to separate base plugin IDs from the derivative ID. | |||
PluginBase::getBaseId | public | function | Gets the base_plugin_id of the plugin instance. | Overrides DerivativeInspectionInterface::getBaseId | |
PluginBase::getDerivativeId | public | function | Gets the derivative_id of the plugin instance. | Overrides DerivativeInspectionInterface::getDerivativeId | |
PluginBase::getPluginDefinition | public | function | Gets the definition of the plugin implementation. | Overrides PluginInspectionInterface::getPluginDefinition | |
PluginBase::getPluginId | public | function | Gets the plugin_id of the plugin instance. | Overrides PluginInspectionInterface::getPluginId | |
PluginBase::isConfigurable | public | function | Determines if the plugin is configurable. | ||
PluginWithFormsTrait::getFormClass | public | function | Implements \Drupal\Core\Plugin\PluginWithFormsInterface::getFormClass(). | ||
PluginWithFormsTrait::hasFormClass | public | function | Implements \Drupal\Core\Plugin\PluginWithFormsInterface::hasFormClass(). | ||
PredefinedStatesWorkflowTestType::addState | public | function | Adds a state to the workflow. | Overrides WorkflowTypeBase::addState | |
PredefinedStatesWorkflowTestType::defaultConfiguration | public | function | Gets default configuration for this plugin. | Overrides WorkflowTypeBase::defaultConfiguration | |
PredefinedStatesWorkflowTestType::deleteState | public | function | Deletes a state from the workflow. | Overrides WorkflowTypeBase::deleteState | |
PredefinedStatesWorkflowTestType::getState | public | function | Gets a workflow state. | Overrides WorkflowTypeBase::getState | |
PredefinedStatesWorkflowTestType::getStates | public | function | Gets state objects for the provided state IDs. | Overrides WorkflowTypeBase::getStates | |
PredefinedStatesWorkflowTestType::hasState | public | function | Determines if the workflow has a state with the provided ID. | Overrides WorkflowTypeBase::hasState | |
PredefinedStatesWorkflowTestType::setStateLabel | public | function | Sets a state's label. | Overrides WorkflowTypeBase::setStateLabel | |
PredefinedStatesWorkflowTestType::setStateWeight | public | function | Sets a state's weight value. | Overrides WorkflowTypeBase::setStateWeight | |
WorkflowTypeBase::addTransition | public | function | Adds a transition to the workflow. | Overrides WorkflowTypeInterface::addTransition | |
WorkflowTypeBase::calculateDependencies | public | function | Calculates dependencies for the configured plugin. | Overrides DependentPluginInterface::calculateDependencies | 1 |
WorkflowTypeBase::deleteTransition | public | function | Deletes a transition. | Overrides WorkflowTypeInterface::deleteTransition | |
WorkflowTypeBase::getConfiguration | public | function | Gets this plugin's configuration. | Overrides ConfigurableInterface::getConfiguration | 1 |
WorkflowTypeBase::getInitialState | public | function | Gets the initial state for the workflow. | Overrides WorkflowTypeInterface::getInitialState | 1 |
WorkflowTypeBase::getNextWeight | protected | function | Gets the weight for a new state or transition. | ||
WorkflowTypeBase::getRequiredStates | public | function | Gets the required states of workflow type. | Overrides WorkflowTypeInterface::getRequiredStates | 1 |
WorkflowTypeBase::getTransition | public | function | Gets a transition object for the provided transition ID. | Overrides WorkflowTypeInterface::getTransition | |
WorkflowTypeBase::getTransitionFromStateToState | public | function | Gets a transition from state to state. | Overrides WorkflowTypeInterface::getTransitionFromStateToState | |
WorkflowTypeBase::getTransitionIdFromStateToState | protected | function | Gets the transition ID from state to state. | ||
WorkflowTypeBase::getTransitions | public | function | Gets transition objects for the provided transition IDs. | Overrides WorkflowTypeInterface::getTransitions | |
WorkflowTypeBase::getTransitionsForState | public | function | Gets the transitions for a state for the provided direction. | Overrides WorkflowTypeInterface::getTransitionsForState | |
WorkflowTypeBase::hasTransition | public | function | Determines if a transition exists. | Overrides WorkflowTypeInterface::hasTransition | |
WorkflowTypeBase::hasTransitionFromStateToState | public | function | Determines if a transition from state to state exists. | Overrides WorkflowTypeInterface::hasTransitionFromStateToState | |
WorkflowTypeBase::label | public | function | Gets the label for the workflow type. | Overrides WorkflowTypeInterface::label | |
WorkflowTypeBase::labelWeightMultisort | protected static | function | Sort states or transitions by weight, label, and key. | ||
WorkflowTypeBase::onDependencyRemoval | public | function | Informs the plugin that a dependency of the workflow will be deleted. | Overrides WorkflowTypeInterface::onDependencyRemoval | 2 |
WorkflowTypeBase::setConfiguration | public | function | Sets the configuration for this plugin instance. | Overrides ConfigurableInterface::setConfiguration | |
WorkflowTypeBase::setTransitionFromStates | public | function | Sets a transition's from states. | Overrides WorkflowTypeInterface::setTransitionFromStates | |
WorkflowTypeBase::setTransitionLabel | public | function | Sets a transition's label. | Overrides WorkflowTypeInterface::setTransitionLabel | |
WorkflowTypeBase::setTransitionWeight | public | function | Sets a transition's weight. | Overrides WorkflowTypeInterface::setTransitionWeight | |
WorkflowTypeBase::VALID_ID_REGEX | constant | A regex for matching a valid state/transition machine name. | |||
WorkflowTypeBase::workflowHasData | public | function | Determines if the workflow is being has data associated with it. | Overrides WorkflowTypeInterface::workflowHasData | 1 |
WorkflowTypeBase::workflowStateHasData | public | function | Determines if the workflow state has data associated with it. | Overrides WorkflowTypeInterface::workflowStateHasData | 1 |
WorkflowTypeBase::__construct | public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | Overrides PluginBase::__construct | 1 |
WorkflowTypeInterface::PLUGIN_FORM_KEY | constant | The key of the global workflow plugin form. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.