Commit 1590d291 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

RoleFormatter : correction pour exploiter la méthode __toString() si présente

parent 1ef203f0
Pipeline #12040 passed with stage
in 25 seconds
......@@ -105,10 +105,9 @@ class UtilisateurController extends AbstractActionController
}
if ($addFlashMessage) {
$selectedRole = $this->serviceUserContext->getSelectedIdentityRole();
$message = sprintf(
"Vous endossez à présent le rôle utilisateur '<strong>%s</strong>'.",
(new RoleFormatter())->format($selectedRole)
$this->serviceUserContext->getSelectedIdentityRoleToString()
);
$this->flashMessenger()->setNamespace('UnicaenAuth/success')->addMessage($message);
}
......
......@@ -29,14 +29,14 @@ class RoleFormatter
{
$formattedRole = '?';
if ($role instanceof RoleInterface) {
$formattedRole = $role->getRoleId();
if (is_string($role)) {
$formattedRole = $role;
}
elseif (is_string($role)) {
elseif (is_object($role) && method_exists($role, '__toString')) {
$formattedRole = (string) $role;
}
elseif (is_object($role) && method_exists($role, '__toString')) {
$formattedRole = $role;
elseif ($role instanceof RoleInterface) {
$formattedRole = $role->getRoleId();
}
return $formattedRole;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment