You are here

private function OpignoModuleController::getLinkOptions in Opigno module 3.x

Same name and namespace in other branches
  1. 8 src/Controller/OpignoModuleController.php \Drupal\opigno_module\Controller\OpignoModuleController::getLinkOptions()

Get bottom options link.

1 call to OpignoModuleController::getLinkOptions()
OpignoModuleController::userResult in src/Controller/OpignoModuleController.php
Returns user result.

File

src/Controller/OpignoModuleController.php, line 1220

Class

OpignoModuleController
Class OpignoModuleController.

Namespace

Drupal\opigno_module\Controller

Code

private function getLinkOptions($free_navigation, $gid, $is_last = FALSE, $current_step = []) : array {
  $link = [];
  $skip_links = \Drupal::request()->query
    ->get('skip-links');

  // Do not show buttons if they do not needed.
  if ($skip_links !== NULL) {
    return $link;
  }

  // Create next/back links.
  $typology = [
    'Meeting',
    'ITL',
  ];
  $options = [
    'attributes' => [
      'class' => [
        'btn',
        'btn-success',
      ],
      'id' => 'edit-submit',
    ],
  ];
  $link['form-actions'] = [
    '#type' => 'container',
    '#attributes' => [
      'class' => [
        'form-actions',
      ],
      'id' => 'edit-actions',
    ],
  ];
  if ($free_navigation || ($is_last || in_array($current_step['typology'], $typology))) {
    $title = $this
      ->t('Back to training homepage');
    $route = 'entity.group.canonical';
    $route_params = [
      'group' => $gid,
    ];
  }
  else {
    $title = t('Next');
    $route = 'opigno_learning_path.steps.next';
    $route_params = [
      'group' => $gid,
      'parent_content' => $current_step['cid'],
    ];
  }
  $link['form-actions'][] = Link::createFromRoute($title, $route, $route_params, $options)
    ->toRenderable();
  return $link;
}