You are here

class PredefinedStatesWorkflowTestType in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/workflows/tests/modules/workflow_type_test/src/Plugin/WorkflowType/PredefinedStatesWorkflowTestType.php \Drupal\workflow_type_test\Plugin\WorkflowType\PredefinedStatesWorkflowTestType
  2. 9 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

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\WorkflowType
View 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

Namesort descending Modifiers Type Description Overrides
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
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
PluginBase::getDerivativeId public function
PluginBase::getPluginDefinition public function 2
PluginBase::getPluginId public function
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
WorkflowTypeBase::calculateDependencies public function
WorkflowTypeBase::deleteTransition public function
WorkflowTypeBase::getConfiguration public function
WorkflowTypeBase::getInitialState public function
WorkflowTypeBase::getNextWeight protected function Gets the weight for a new state or transition.
WorkflowTypeBase::getRequiredStates public function 1
WorkflowTypeBase::getTransition public function
WorkflowTypeBase::getTransitionFromStateToState public function
WorkflowTypeBase::getTransitionIdFromStateToState protected function Gets the transition ID from state to state.
WorkflowTypeBase::getTransitions public function
WorkflowTypeBase::getTransitionsForState public function
WorkflowTypeBase::hasTransition public function
WorkflowTypeBase::hasTransitionFromStateToState public function
WorkflowTypeBase::label public function
WorkflowTypeBase::labelWeightMultisort protected static function Sort states or transitions by weight, label, and key.
WorkflowTypeBase::onDependencyRemoval public function 1
WorkflowTypeBase::setConfiguration public function
WorkflowTypeBase::setTransitionFromStates public function
WorkflowTypeBase::setTransitionLabel public function
WorkflowTypeBase::setTransitionWeight public function
WorkflowTypeBase::VALID_ID_REGEX constant A regex for matching a valid state/transition machine name.
WorkflowTypeBase::workflowHasData public function
WorkflowTypeBase::workflowStateHasData public function
WorkflowTypeBase::__construct public function
WorkflowTypeInterface::PLUGIN_FORM_KEY constant The key of the global workflow plugin form.