annotations.rst 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. Annotations
  2. ===========
  3. All annotations require jms/di-extra-bundle, it can easily be installed by composer:
  4. .. code-block:: bash
  5. composer require jms/di-extra-bundle
  6. if you want to know more: http://jmsyst.com/bundles/JMSDiExtraBundle
  7. The annotations get registered with JMSDiExtraBundle automatically if it is installed.
  8. If you need to disable this for some reason, you can do this via the configuration:
  9. .. configuration-block::
  10. .. code-block:: yaml
  11. sonata_admin:
  12. options:
  13. enable_jms_di_extra_autoregistration: false
  14. .. note::
  15. Starting with version 4.0, SonataAdminBundle will no longer register
  16. annotations with JMSDiExtraBundle automatically. Please add the following to
  17. your config.yml to register the annotations yourself:
  18. .. code-block:: yaml
  19. jms_di_extra:
  20. annotation_patterns:
  21. - JMS\DiExtraBundle\Annotation
  22. - Sonata\AdminBundle\Annotation
  23. Define Admins
  24. ^^^^^^^^^^^^^
  25. All you have to do is include ``Sonata\AdminBundle\Annotation`` and define the values you need.
  26. .. code-block:: php
  27. <?php
  28. namespace AcmeBundle\Admin;
  29. use Sonata\AdminBundle\Admin\AbstractAdmin;
  30. use Sonata\AdminBundle\Annotation as Sonata;
  31. /**
  32. * @Sonata\Admin(
  33. * class="AcmeBundle\Entity\MyEntity",
  34. * id="service id (generated per default)",
  35. * managerType="doctrine_mongodb (orm per default)",
  36. * baseControllerName="SonataAdminBundle:CRUD",
  37. * group="myGroup",
  38. * label="myLabel",
  39. * showInDashboard=true,
  40. * translationDomain="OMG",
  41. * pagerType="",
  42. * persistFilters="",
  43. * icon="<i class='fa fa-folder'></i>",
  44. * keepOpen=false,
  45. * onTop=false
  46. * )
  47. */
  48. class MyAdmin extends AbstractAdmin
  49. {
  50. }
  51. .. note::
  52. If you need to define custom controllers you can also use jms/di-extra-bundle by using
  53. the DI\Service annotation.