You are here

class FormsStepsProgressBarBlock in Forms Steps 8

Same name in this branch
  1. 8 src/Plugin/Derivative/FormsStepsProgressBarBlock.php \Drupal\forms_steps\Plugin\Derivative\FormsStepsProgressBarBlock
  2. 8 src/Plugin/Block/FormsStepsProgressBarBlock.php \Drupal\forms_steps\Plugin\Block\FormsStepsProgressBarBlock

Provides block plugin definitions for progress bars.

Hierarchy

Expanded class hierarchy of FormsStepsProgressBarBlock

See also

\Drupal\forms_steps\Plugin\Block\FormsStepsProgressBarBlock

File

src/Plugin/Derivative/FormsStepsProgressBarBlock.php, line 15

Namespace

Drupal\forms_steps\Plugin\Derivative
View source
class FormsStepsProgressBarBlock extends DeriverBase implements ContainerDeriverInterface {

  /**
   * The forms steps storage.
   *
   * @var \Drupal\Core\Entity\EntityStorageInterface
   */
  protected $formStepsStorage;

  /**
   * Constructs new forms steps progress bar block.
   *
   * @param \Drupal\Core\Entity\EntityStorageInterface $forms_steps_storage
   *   The forms steps storage.
   */
  public function __construct(EntityStorageInterface $forms_steps_storage) {
    $this->formStepsStorage = $forms_steps_storage;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static($container
      ->get('entity_type.manager')
      ->getStorage('forms_steps'));
  }

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {

    // Load all available forms steps.
    $forms_steps_entities = $this->formStepsStorage
      ->loadMultiple();
    foreach ($forms_steps_entities as $forms_steps) {
      $progress_steps = $forms_steps
        ->getProgressSteps();
      if (count($progress_steps)) {
        $this->derivatives[$forms_steps
          ->id()] = $base_plugin_definition;
        $this->derivatives[$forms_steps
          ->id()]['admin_label'] = t('Forms Steps - :title (Progress bar)', [
          ':title' => $forms_steps
            ->label(),
        ]);
      }
    }
    return $this->derivatives;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
FormsStepsProgressBarBlock::$formStepsStorage protected property The forms steps storage.
FormsStepsProgressBarBlock::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
FormsStepsProgressBarBlock::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
FormsStepsProgressBarBlock::__construct public function Constructs new forms steps progress bar block.