php - How to manage roles in symfony2 application -


I have a web application where I have 5 level users like

  1. Administrators <
  2. Organization
  3. Localization
  4. Teacher
  5. Guardian
  6. Student P> Now every user has a different landing page or some other or less tabs or features.

    Now I want to know that I make it as only one entity and then play different units so that I can simplify the login process <

    Here is an example of how you will go about it

    Your Controller:

     < Code> Public Function Index () {$ user = $ this- & gt; Container-> Get ('security.context') - & gt; GetToken () - & gt; GetUser); $ $ Return - ('Your bundle: Page: index.html.twig', Array ('user_role' = & gt; $ user- & gt; getRole ())); }   

    Toggle:

      {% user_role == "Admin"%} Menu 1, Menu 2, Menu 3 {% elseif user_role == "Organization The title of "%} menu 1, menu 4 {% elseif user_role ==" etc "%} menu 5 {% endif%}    

Comments