public function UserAchievements::switchTabs in Opigno statistics 3.x
Ajax callback to swith tabs content.
Parameters
\Drupal\user\UserInterface $user: The user to render the content for.
string $tab: The tab machine name to be displayed.
Return value
\Drupal\Core\Ajax\AjaxResponse The ajax response to display the tab content.
1 string reference to 'UserAchievements::switchTabs'
File
- src/
Controller/ UserAchievements.php, line 206
Class
- UserAchievements
- User achievements page controller.
Namespace
Drupal\opigno_statistics\ControllerCode
public function switchTabs(UserInterface $user, string $tab) : AjaxResponse {
$uid = (int) $user
->id();
$content = $this
->getTabContent($uid, $tab);
$title = $this
->getTabTitle($tab);
// Update the title, the content and the active tab.
$response = new AjaxResponse();
$response
->addCommand(new HtmlCommand('#opigno-achievements-content h2', $title));
$response
->addCommand(new HtmlCommand('#opigno-achievements-content .tab-content', $content));
$response
->addCommand(new InvokeCommand('.achievements-tabs a', 'removeClass', [
'active',
]));
$response
->addCommand(new InvokeCommand(".achievements-tabs a.{$tab}", 'addClass', [
'active',
]));
return $response;
}