public function isUserInRole(string $role) { // query whether or not we've an user principal if ($principal = $this->getUserPrincipal()) { return $principal->getRoles()->contains($role); } // user is not in passed role return false; }