I'm trying to get my user role thanks to a function in my theme.theme file.
function theme_get_user_role(){
$current_user = \Drupal::currentUser();
$roles = $current_user->getRoles();
}
then in my view :
{% set roles = theme_get_user_role() %}
{{ dump(roles) }}
But I have this error :
Twig_Error_Syntax : Unknown "theme_get_user_role" function. dans Twig_ExpressionParser->getFunctionNodeClass()
What do I miss ?
theme_preprocess_views_view(&$variables)
where you'd do your logic and then add the output to$variables['foo'] = 'bar'
and in the corresponding template then access it via{{ bar }}
.