Using Groups With FOSUserBundle
===============================
FOSUserBundle allows you to associate groups to your users. Groups are a
way to group a collection of roles. The roles of a group will be granted
to all users belonging to it.
.. note::
Symfony supports role inheritance so inheriting roles from groups is
not always needed. If the role inheritance is enough for your use case,
it is better to use it instead of groups as it is more efficient (loading
the groups triggers the database).
To use the groups, you need to explicitly enable this functionality in your
configuration. The only mandatory configuration is the fully qualified class
name (FQCN) of your ``Group`` class which must implement ``FOS\UserBundle\Model\GroupInterface``.
Below is an example configuration for enabling groups support.
.. configuration-block::
.. code-block:: yaml
# app/config/config.yml
fos_user:
db_driver: orm
firewall_name: main
user_class: AppBundle\Entity\User
group:
group_class: AppBundle\Entity\Group
.. code-block:: xml
The Group class
---------------
The simplest way to create a Group class is to extend the mapped superclass
provided by the bundle.
a) ORM Group class implementation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. configuration-block::
.. code-block:: php-annotations
b) MongoDB User-Group mapping
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: php