You are here

public function UserController::ajaxLoadCourseModuleDetails in Opigno statistics 8

Same name and namespace in other branches
  1. 3.x src/Controller/UserController.php \Drupal\opigno_statistics\Controller\UserController::ajaxLoadCourseModuleDetails()

Loads module panel with a AJAX.

Parameters

\Drupal\user\UserInterface $user: User.

\Drupal\group\Entity\GroupInterface $training: Training.

null|\Drupal\group\Entity\GroupInterface $course: Course.

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

Return value

\Drupal\Core\Ajax\AjaxResponse AJAX response.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 string reference to 'UserController::ajaxLoadCourseModuleDetails'
opigno_statistics.routing.yml in ./opigno_statistics.routing.yml
opigno_statistics.routing.yml

File

src/Controller/UserController.php, line 1069

Class

UserController
Class UserController.

Namespace

Drupal\opigno_statistics\Controller

Code

public function ajaxLoadCourseModuleDetails(UserInterface $user, GroupInterface $training, GroupInterface $course, OpignoModule $module) {
  $training_id = $training
    ->id();
  $course_id = $course
    ->id();
  $module_id = $module
    ->id();
  $user_id = $user
    ->id();
  $selector = "#module_panel_{$user_id}_{$training_id}_{$course_id}_{$module_id}";
  $content = $this
    ->buildModuleDetails($user, $training, $course, $module);
  $content['#attributes']['data-ajax-loaded'] = TRUE;
  $response = new AjaxResponse();
  $response
    ->addCommand(new ReplaceCommand($selector, $content));
  return $response;
}