You are here

class WorkflowState in State Machine 8

Defines the class for workflow states.

Hierarchy

Expanded class hierarchy of WorkflowState

1 file declares its use of WorkflowState
StateItem.php in src/Plugin/Field/FieldType/StateItem.php

File

src/Plugin/Workflow/WorkflowState.php, line 8

Namespace

Drupal\state_machine\Plugin\Workflow
View source
class WorkflowState {

  /**
   * The state ID.
   *
   * @var string
   */
  protected $id;

  /**
   * The state label.
   *
   * @var string
   */
  protected $label;

  /**
   * Constructs a new WorkflowState object.
   *
   * @param string $id
   *   The state ID.
   * @param string $label
   *   The state label.
   */
  public function __construct($id, $label) {
    $this->id = $id;
    $this->label = $label;
  }

  /**
   * Gets the ID.
   *
   * @return string
   *   The ID.
   */
  public function getId() {
    return $this->id;
  }

  /**
   * Gets the translated label.
   *
   * @return string
   *   The translated label.
   */
  public function getLabel() {
    return (string) t($this->label, [], [
      'context' => 'workflow state',
    ]);
  }

  /**
   * Gets the string representation of the workflow state.
   *
   * @return string
   *   The string representation of the workflow state.
   */
  public function __toString() {
    return $this
      ->getLabel();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
WorkflowState::$id protected property The state ID.
WorkflowState::$label protected property The state label.
WorkflowState::getId public function Gets the ID.
WorkflowState::getLabel public function Gets the translated label.
WorkflowState::__construct public function Constructs a new WorkflowState object.
WorkflowState::__toString public function Gets the string representation of the workflow state.