You are here

protected function StepsBlock::buildState in Opigno Learning path 8

Builds the state.

Parameters

array $step:

Return value

string|null

1 call to StepsBlock::buildState()
StepsBlock::build in src/Plugin/Block/StepsBlock.php
Builds and returns the renderable array for this block plugin.

File

src/Plugin/Block/StepsBlock.php, line 321

Class

StepsBlock
Provides a 'article' block.

Namespace

Drupal\opigno_learning_path\Plugin\Block

Code

protected function buildState(array $step) {
  $uid = \Drupal::currentUser()
    ->id();
  $status = opigno_learning_path_get_step_status($step, $uid, TRUE);
  $class = [
    'pending' => 'lp_steps_block_step_pending',
    'failed' => 'lp_steps_block_step_failed',
    'passed' => 'lp_steps_block_step_passed',
  ];
  if (isset($class[$status])) {
    return [
      'data' => [
        '#type' => 'html_tag',
        '#tag' => 'span',
        '#attributes' => [
          'class' => [
            $class[$status],
          ],
        ],
      ],
    ];
  }
  else {
    return [
      'data' => [
        '#markup' => '‐',
      ],
    ];
  }
}