You are here

public function OpignoGroupManagerController::getNextLink in Opigno group manager 8

Same name and namespace in other branches
  1. 3.x src/Controller/OpignoGroupManagerController.php \Drupal\opigno_group_manager\Controller\OpignoGroupManagerController::getNextLink()

Returns next link.

File

src/Controller/OpignoGroupManagerController.php, line 135

Class

OpignoGroupManagerController
Controller for all the actions of the Opigno group manager app.

Namespace

Drupal\opigno_group_manager\Controller

Code

public function getNextLink(Group $group) {
  $next_link = NULL;
  if ($group instanceof GroupInterface) {
    $current_step = opigno_learning_path_get_current_step();
    $next_step = $current_step < 5 ? $current_step + 1 : NULL;
    $link_text = !$next_step ? $this
      ->t('Publish') : $this
      ->t('Next');
    $next_link = Link::createFromRoute($link_text, 'opigno_learning_path.content_steps', [
      'group' => $group
        ->id(),
      'current' => $current_step ? $current_step : 0,
    ], [
      'attributes' => [
        'class' => [
          'btn',
          'btn-success',
          'color-white',
        ],
      ],
    ])
      ->toRenderable();
  }
  return $next_link;
}