You are here

protected function LearningPathStepsController::redirectToHome in Opigno Learning path 3.x

Same name and namespace in other branches
  1. 8 src/Controller/LearningPathStepsController.php \Drupal\opigno_learning_path\Controller\LearningPathStepsController::redirectToHome()

Redirect to the group homepage.

Parameters

string $message:

bool $is_ajax:

2 calls to LearningPathStepsController::redirectToHome()
LearningPathStepsController::failedStep in src/Controller/LearningPathStepsController.php
Provide a default failed messages for the learning path.
LearningPathStepsController::start in src/Controller/LearningPathStepsController.php
Start the learning path.

File

src/Controller/LearningPathStepsController.php, line 80

Class

LearningPathStepsController
Class LearningPathStepsController.

Namespace

Drupal\opigno_learning_path\Controller

Code

protected function redirectToHome($message = '', $is_ajax = FALSE) {
  if (!empty($this->group) && !empty($this->source_type) && $this->source_type == 'catalog') {
    if ($is_ajax) {
      $url = Url::fromRoute('entity.group.canonical', [
        'group' => $this->group
          ->id(),
        'force' => 1,
      ]);
      return (new AjaxResponse())
        ->addCommand(new RedirectCommand($url
        ->toString()));
    }
    else {
      return $this
        ->redirect('entity.group.canonical', [
        'group' => $this->group
          ->id(),
        'force' => 1,
      ]);
    }
  }
  return FALSE;
}