title: Symfony 2 - Accessing Hierarchical Roles in a twig template
body: <p>In my template, I need to know if a user has certain role to display things according to it. So far, I've implemented a little function in my user class:</p>
  
  <pre><code>  public function hasRole($role) {
      $roles = array();
      foreach ($this-&gt;getRoles() as $rol) {
        $roles[] = $rol-&gt;getRole();
      }
      return in_array($role, $roles);
    }
  </code></pre>
  
  <p>which tells me if this user has the role specified by the string passed as a parameter. This work and can be called from a twig template, but doesn't allow me to know anything about the roles hierarchy. Is there a way to access the role hierarchy from a controller? and directly from a twig template? I've looked through the official docs and didn't find anything about.</p>