You are here

class FormsStepsHelper in Forms Steps 8

Class FormsStepsHelper.

@package Drupal\forms_steps\Service

Hierarchy

Expanded class hierarchy of FormsStepsHelper

1 file declares its use of FormsStepsHelper
FormsStepsProgressBarBlock.php in src/Plugin/Block/FormsStepsProgressBarBlock.php
1 string reference to 'FormsStepsHelper'
forms_steps.services.yml in ./forms_steps.services.yml
forms_steps.services.yml
1 service uses FormsStepsHelper
forms_steps.helper in ./forms_steps.services.yml
Drupal\forms_steps\Service\FormsStepsHelper

File

src/Service/FormsStepsHelper.php, line 12

Namespace

Drupal\forms_steps\Service
View source
class FormsStepsHelper {

  /**
   * FormsStepsManager.
   *
   * @var \Drupal\forms_steps\Service\FormsStepsManager
   */
  protected $formsStepsManager;

  /**
   * CurrentRouteMatch.
   *
   * @var \Drupal\Core\Routing\CurrentRouteMatch
   */
  private $currentRouteMatch;

  /**
   * FormsStepsHelper constructor.
   *
   * @param \Drupal\forms_steps\Service\FormsStepsManager $forms_steps_manager
   *   Injected FormsStepsManager instance.
   * @param \Drupal\Core\Routing\CurrentRouteMatch $current_route_match
   *   Injected current route match instance.
   */
  public function __construct(FormsStepsManager $forms_steps_manager, CurrentRouteMatch $current_route_match) {
    $this->formsStepsManager = $forms_steps_manager;
    $this->currentRouteMatch = $current_route_match;
  }

  /**
   * Get the workflow instance ID if in a current forms steps route.
   *
   * @return false|string
   *   Return the Instance ID or FALSE otherwise.
   */
  public function getWorkflowInstanceIdFromRoute() {
    $step = $this->formsStepsManager
      ->getStepByRoute($this->currentRouteMatch
      ->getRouteName());

    // Only return the workflow instance id if the current route is a forms
    // steps route.
    if ($step) {
      $instanceId = $this->currentRouteMatch
        ->getParameter('instance_id');
      return $instanceId;
    }
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FormsStepsHelper::$currentRouteMatch private property CurrentRouteMatch.
FormsStepsHelper::$formsStepsManager protected property FormsStepsManager.
FormsStepsHelper::getWorkflowInstanceIdFromRoute public function Get the workflow instance ID if in a current forms steps route.
FormsStepsHelper::__construct public function FormsStepsHelper constructor.