You are here

public function LearningPathAchievementController::training_module_panel_ajax in Opigno Learning path 8

Same name and namespace in other branches
  1. 3.x src/Controller/LearningPathAchievementController.php \Drupal\opigno_learning_path\Controller\LearningPathAchievementController::training_module_panel_ajax()

Loads module panel with a AJAX.

Parameters

\Drupal\group\Entity\GroupInterface $group: Group.

\Drupal\opigno_module\Entity\OpignoModule $opigno_module: Opigno module.

Return value

\Drupal\Core\Ajax\AjaxResponse Response.

1 string reference to 'LearningPathAchievementController::training_module_panel_ajax'
opigno_learning_path.routing.yml in ./opigno_learning_path.routing.yml
opigno_learning_path.routing.yml

File

src/Controller/LearningPathAchievementController.php, line 1018

Class

LearningPathAchievementController
Class LearningPathAchievementController.

Namespace

Drupal\opigno_learning_path\Controller

Code

public function training_module_panel_ajax(GroupInterface $group, OpignoModule $opigno_module) {
  $training_id = $group
    ->id();
  $module_id = $opigno_module
    ->id();
  $selector = "#module_panel_{$training_id}_{$module_id}";
  $content = $this
    ->build_module_panel($group, NULL, $opigno_module);
  $content['#attributes']['data-ajax-loaded'] = TRUE;
  $response = new AjaxResponse();
  $response
    ->addCommand(new ReplaceCommand($selector, $content));
  return $response;
}