title: How can I pass a full security roles list/hierarchy to a FormType class in Symfony2?
body: <p>I have a user edit form where I would like to administer the roles assigned to a user.</p>
  
  <p>Currently I have a multi-select list, but I have no way of populating it with the role hierarchy defined in security.yml.</p>
  
  <p>Is there some way that I get this information to the form builder in the FormType class?</p>
  
  <pre><code>$builder-&gt;add('roles', 'choice', array(
                  'required' =&gt; true,
                  'multiple' =&gt; true,
                  'choices' =&gt; array(),
              ));
  </code></pre>
  
  <p>Looking around <a href="https://stackoverflow.com/a/8931181/461813">I found</a> that I can get the roles from the container in a controller with:</p>
  
  <pre><code>$roles = $this-&gt;container-&gt;getParameter('security.role_hierarchy.roles');
  </code></pre>
  
  <p>I have also discovered that I could potentially set this as a dependency to be injected on the FormType class in services.xml:</p>
  
  <pre><code>&lt;parameters&gt;
      &lt;parameter key="security.role_heirarchy.roles"&gt;ROLE_GUEST&lt;/parameter&gt;
  &lt;/parameters&gt;
  &lt;services&gt;
      &lt;service id="base.user.form.type.user_form" class="Base\UserBundle\Form\UserType" public="false"&gt;
          &lt;tag name="form.type" /&gt;
          &lt;call method="setRoles"&gt;
              &lt;argument&gt;%security.role_heirarchy.roles%&lt;/argument&gt;
          &lt;/call&gt;
      &lt;/service&gt;
  &lt;/services&gt;
  </code></pre>
  
  <p>This however does not work and does not seem to ever call the <code>setRoles</code> method.</p>
  
  <p>So how can I get this to work?</p>