You are here

class Step in Forms Steps 8

A value object representing a step state.

Hierarchy

Expanded class hierarchy of Step

5 files declare their use of Step
FormsSteps.php in src/Entity/FormsSteps.php
FormsStepsAlter.php in src/Form/FormsStepsAlter.php
RouteHelper.php in src/Service/RouteHelper.php
StepChangeEvent.php in src/Event/StepChangeEvent.php
WorkflowListBuilder.php in src/Controller/WorkflowListBuilder.php
4 string references to 'Step'
FormsStepsEditForm::form in src/Form/FormsStepsEditForm.php
Gets the actual form array to be built.
FormsStepsStepFormBase::form in src/Form/FormsStepsStepFormBase.php
Gets the actual form array to be built.
forms_steps.schema.yml in config/schema/forms_steps.schema.yml
config/schema/forms_steps.schema.yml
WorkflowListBuilder::buildHeader in src/Controller/WorkflowListBuilder.php
Building the header and content lines for the contact list.

File

src/Step.php, line 8

Namespace

Drupal\forms_steps
View source
class Step implements StepInterface {

  /**
   * The forms_steps the step is attached to.
   *
   * @var \Drupal\forms_steps\FormsStepsInterface
   */
  protected $formsSteps;

  /**
   * The step's ID.
   *
   * @var string
   */
  protected $id;

  /**
   * The step's label.
   *
   * @var string
   */
  protected $label;

  /**
   * The step's weight.
   *
   * @var int
   */
  protected $weight;

  /**
   * The step's entity_type.
   *
   * @var string
   */
  protected $entityType;

  /**
   * The step's entity_bundle.
   *
   * @var string
   */
  protected $entityBundle;

  /**
   * The step's form_view_mode_id.
   *
   * @var string
   */
  protected $formMode;

  /**
   * The step's URL.
   *
   * @var string
   */
  protected $url;

  /**
   * The step's submit label.
   *
   * @var string
   */
  protected $submitLabel;

  /**
   * The step's cancel label.
   *
   * @var string
   */
  protected $cancelLabel;

  /**
   * The step's delete label.
   *
   * @var string
   */
  protected $deleteLabel;

  /**
   * The step's cancel route.
   *
   * @var string
   */
  protected $cancelRoute;

  /**
   * The step's cancel step.
   *
   * @var \Drupal\forms_steps\Step
   */
  protected $cancelStep;

  /**
   * The step's cancel step mode.
   *
   * @var string
   */
  protected $cancelStepMode;

  /**
   * The step's delete state.
   *
   * @var bool
   */
  protected $hideDelete;

  /**
   * The step's previous label.
   *
   * @var string
   */
  protected $previousLabel;

  /**
   * The step's previous state.
   *
   * @var bool
   */
  protected $displayPrevious;

  /**
   * Step constructor.
   *
   * @param \Drupal\forms_Steps\FormsStepsInterface $forms_steps
   *   The forms_steps the step is attached to.
   * @param string $id
   *   The step's ID.
   * @param string $label
   *   The step's label.
   * @param int $weight
   *   The step's weight.
   * @param string $entityType
   *   The step's entity type.
   * @param string $entityBundle
   *   The step's bundle.
   * @param string $formMode
   *   The step's form mode.
   * @param string $url
   *   The step's URL.
   */
  public function __construct(FormsStepsInterface $forms_steps, $id, $label, $weight, $entityType, $entityBundle, $formMode, $url) {
    $this->formsSteps = $forms_steps;
    $this->id = $id;
    $this->label = $label;
    $this->weight = $weight;
    $this->entityType = $entityType;
    $this->entityBundle = $entityBundle;
    $this->formMode = $formMode;
    $this->url = $url;
  }

  /**
   * {@inheritdoc}
   */
  public function id() {
    return $this->id;
  }

  /**
   * {@inheritdoc}
   */
  public function label() {
    return $this->label;
  }

  /**
   * {@inheritdoc}
   */
  public function weight() {
    return $this->weight;
  }

  /**
   * {@inheritdoc}
   */
  public function entityType() {
    return $this->entityType;
  }

  /**
   * {@inheritdoc}
   */
  public function entityBundle() {
    return $this->entityBundle;
  }

  /**
   * {@inheritdoc}
   */
  public function formMode() {
    return $this->formMode;
  }

  /**
   * {@inheritdoc}
   */
  public function url() {
    return $this->url;
  }

  /**
   * Return a list of form modes available for this entity bundle.
   *
   * @return array
   *   Returns the list of form modes.
   */
  public function formModes() {
    $result = [];

    // Get the list of available form modes for a certain entity type.
    $form_modes = \Drupal::service('entity_display.repository')
      ->getFormModes($this->entityType);
    foreach ($form_modes as $form_mode) {
      $result[$form_mode['id']] = $form_mode['label'];
    }
    $result['default'] = 'Default';
    return $result;
  }

  /**
   * Gets the submit label.
   *
   * @return string
   *   The submit label.
   */
  public function submitLabel() {
    return $this->submitLabel;
  }

  /**
   * Gets the cancel label.
   *
   * @return string
   *   The cancel label.
   */
  public function cancelLabel() {
    return $this->cancelLabel;
  }

  /**
   * Gets the delete label.
   *
   * @return string
   *   The delete label.
   */
  public function deleteLabel() {
    return $this->deleteLabel;
  }

  /**
   * Gets the cancel route.
   *
   * @return string
   *   The cancel route.
   */
  public function cancelRoute() {
    return $this->cancelRoute;
  }

  /**
   * Gets the cancel step.
   *
   * @return \Drupal\forms_steps\Step
   *   The cancel step.
   */
  public function cancelStep() {
    return $this->cancelStep;
  }

  /**
   * Get the hidden status of the delete button.
   *
   * @return bool
   *   TRUE if hidden | FALSE otherwise
   */
  public function hideDelete() {
    return $this->hideDelete;
  }

  /**
   * Set the hidden state of the delete button.
   *
   * @param bool $value
   *   TRUE if hidden | FALSE otherwise.
   */
  public function setHideDelete($value) {
    $this->hideDelete = $value;
  }

  /**
   * Gets the cancel step mode.
   *
   * @return string
   *   The cancel step mode.
   */
  public function cancelStepMode() {
    return $this->cancelStepMode;
  }

  /**
   * {@inheritdoc}
   */
  public function setSubmitLabel($label) {
    $this->submitLabel = $label;
  }

  /**
   * {@inheritdoc}
   */
  public function setCancelLabel($label) {
    $this->cancelLabel = $label;
  }

  /**
   * {@inheritdoc}
   */
  public function setDeleteLabel($label) {
    $this->deleteLabel = $label;
  }

  /**
   * {@inheritdoc}
   */
  public function setCancelRoute($route) {
    $this->cancelRoute = $route;
  }

  /**
   * {@inheritdoc}
   */
  public function setCancelStep(Step $step) {
    $this->cancelStep = $step;
  }

  /**
   * {@inheritdoc}
   */
  public function setCancelStepMode($mode) {
    $this->cancelStepMode = $mode;
  }

  /**
   * {@inheritdoc}
   */
  public function formsSteps() {
    return $this->formsSteps;
  }

  /**
   * {@inheritdoc}
   */
  public function displayPrevious() {
    return $this->displayPrevious;
  }

  /**
   * {@inheritdoc}
   */
  public function setPreviousLabel($label) {
    $this->previousLabel = $label;
  }

  /**
   * {@inheritdoc}
   */
  public function previousLabel() {
    return $this->previousLabel;
  }

  /**
   * {@inheritdoc}
   */
  public function setDisplayPrevious($value) {
    return $this->displayPrevious = $value;
  }

  /**
   * {@inheritdoc}
   */
  public function isLast() {
    $last_step = $this->formsSteps
      ->getLastStep();
    if ($this->id == $last_step
      ->id()) {
      return TRUE;
    }
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Step::$cancelLabel protected property The step's cancel label.
Step::$cancelRoute protected property The step's cancel route.
Step::$cancelStep protected property The step's cancel step.
Step::$cancelStepMode protected property The step's cancel step mode.
Step::$deleteLabel protected property The step's delete label.
Step::$displayPrevious protected property The step's previous state.
Step::$entityBundle protected property The step's entity_bundle.
Step::$entityType protected property The step's entity_type.
Step::$formMode protected property The step's form_view_mode_id.
Step::$formsSteps protected property The forms_steps the step is attached to.
Step::$hideDelete protected property The step's delete state.
Step::$id protected property The step's ID.
Step::$label protected property The step's label.
Step::$previousLabel protected property The step's previous label.
Step::$submitLabel protected property The step's submit label.
Step::$url protected property The step's URL.
Step::$weight protected property The step's weight.
Step::cancelLabel public function Gets the cancel label. Overrides StepInterface::cancelLabel
Step::cancelRoute public function Gets the cancel route. Overrides StepInterface::cancelRoute
Step::cancelStep public function Gets the cancel step. Overrides StepInterface::cancelStep
Step::cancelStepMode public function Gets the cancel step mode. Overrides StepInterface::cancelStepMode
Step::deleteLabel public function Gets the delete label.
Step::displayPrevious public function Get the display status of the previous button. Overrides StepInterface::displayPrevious
Step::entityBundle public function Gets the step's bundle. Overrides StepInterface::entityBundle
Step::entityType public function Gets the step's entity type. Overrides StepInterface::entityType
Step::formMode public function Gets the step's form mode. Overrides StepInterface::formMode
Step::formModes public function Return a list of form modes available for this entity bundle.
Step::formsSteps public function Get the forms steps object parent to this step. Overrides StepInterface::formsSteps
Step::hideDelete public function Get the hidden status of the delete button. Overrides StepInterface::hideDelete
Step::id public function Gets the step's ID. Overrides StepInterface::id
Step::isLast public function Determines if the step is the last one on its forms steps entity. Overrides StepInterface::isLast
Step::label public function Gets the step's label. Overrides StepInterface::label
Step::previousLabel public function Gets the previous label. Overrides StepInterface::previousLabel
Step::setCancelLabel public function Set the cancel label. Overrides StepInterface::setCancelLabel
Step::setCancelRoute public function Set the cancel route. Overrides StepInterface::setCancelRoute
Step::setCancelStep public function Set the cancel step. Overrides StepInterface::setCancelStep
Step::setCancelStepMode public function Set the cancel step mode. Overrides StepInterface::setCancelStepMode
Step::setDeleteLabel public function Set the delete label. Overrides StepInterface::setDeleteLabel
Step::setDisplayPrevious public function Set the display state of the previous button. Overrides StepInterface::setDisplayPrevious
Step::setHideDelete public function Set the hidden state of the delete button. Overrides StepInterface::setHideDelete
Step::setPreviousLabel public function Set the previous label. Overrides StepInterface::setPreviousLabel
Step::setSubmitLabel public function Set the submit label. Overrides StepInterface::setSubmitLabel
Step::submitLabel public function Gets the submit label. Overrides StepInterface::submitLabel
Step::url public function Gets the step's url. Overrides StepInterface::url
Step::weight public function Gets the step's weight. Overrides StepInterface::weight
Step::__construct public function Step constructor.