+               //Get the unique roles list by id
+               return array_unique(array_reduce(
+                       //Cast groups as array
+                       $this->groups->toArray(),
+                       //Reduce to an array of id => group tuples
+                       function ($array, $group) {
+                               $array[$group->getId()] = $group->getRole();
+                               return $array;
+                       },
+                       //Init with ROLE_USER
+                       //XXX: we assume that ROLE_USER has id 1 in database
+                       [ 1 => 'ROLE_USER' ]
+               ));
+       }
+
+       public function getRole() {
+               //Retrieve roles
+               $roles = $this->getRoles();
+
+               //Return the role with max id
+               //XXX: should be rewriten if it change in your configuration
+               return $roles[array_reduce(
+                       array_keys($roles),
+                       function($cur, $id) {
+                               if ($id > $cur) {
+                                       return $id;
+                               }
+                               return $cur;
+                       },
+                       0
+               )];