-
Notifications
You must be signed in to change notification settings - Fork 0
UserManagerInterface
Alexander Saal edited this page Aug 4, 2025
·
1 revision
interface UserManagerInterface
{
/**
* Returns the SDK UserInterface for the specified user name.
*
* @param string $userName Name of the user to be returned
*
* @return \JobRouter\Sdk\UserInterface the SDK UserInterface for the specified user name.
*
* @throws \JobRouterException
* @throws \JobRouter\Authentication\NoActiveAuthenticationException
* @throws \NoInstanceFoundException
*/
public function getUserByUsername(string $userName): \JobRouter\Sdk\UserInterface;
/**
* Returns the currently logged-in JobRouter user as SDK UserInterface.
*
* @return \JobRouter\Sdk\UserInterface the currently logged in JobRouter user as SDK user.
*
* @throws \JobRouterException
* @throws \JobRouter\Authentication\NoActiveAuthenticationException
* @throws \NoInstanceFoundException
*/
public function getCurrentUser(): \JobRouter\Sdk\UserInterface;
}
<?php
use JobRouter\Sdk\UserManagerInterface;
return function (UserManagerInterface $userManagerInterface): void {
echo '<h1 style="color: #fc0">JobRouter SDK user interface example!</h1>';
try {
$currentUser = $userManagerInterface->getCurrentUser();
// Do something with the $currentUser
$userByName = $userManagerInterface->getUserByUsername('example_user');
// Do something with the $userByName
} catch (\NoInstanceFoundException) {
echo '<h3 style="color: #f44;">The user does not exist!</h3>';
}
};