doctrine.rst 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. More about Doctrine implementations
  2. ===================================
  3. FOSUserBundle was first written for Doctrine-based storage layers. This chapter
  4. describes some things specific to these implementations.
  5. Using a different object manager than the default one
  6. -----------------------------------------------------
  7. Using the default configuration , FOSUserBundle will use the default doctrine
  8. object manager. If you are using multiple ones and want to handle your users
  9. with a non-default one, you can change the object manager used in the configuration
  10. by giving its name to FOSUserBundle.
  11. .. code-block:: yaml
  12. # app/config/config.yml
  13. fos_user:
  14. db_driver: orm
  15. model_manager_name: non_default # the name of your entity manager
  16. .. note::
  17. Using the default object manager is done by setting the configuration
  18. option to ``null`` which is the default value.
  19. Replacing the mapping of the bundle
  20. -----------------------------------
  21. None of the Doctrine projects currently allow overwriting part of the mapping
  22. of a mapped superclass in the child entity.
  23. If you need to change the mapping (for instance to adapt the field names
  24. to a legacy database), one solution could be to write the whole mapping again
  25. without inheriting the mapping from the mapped superclass. In such case,
  26. your entity should extend directly from ``FOS\UserBundle\Model\User`` (and
  27. ``FOS\UserBundle\Model\Group`` for the group). Another solution can be through
  28. `doctrine attribute and relations overrides`_.
  29. .. caution::
  30. It is highly recommended to map all fields used by the bundle (see the
  31. mapping files of the bundle in ``Resources/config/doctrine/``). Omitting
  32. them can lead to unexpected behaviors and should be done carefully.
  33. .. _doctrine attribute and relations overrides: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/inheritance-mapping.html#overrides