annotations.rst 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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\AdminBundleAnnotations 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. * )
  35. */
  36. class MyAdmin extends AbstractAdmin
  37. {
  38. }
  39. .. note::
  40. If you need to define custom controllers you can also use jms/di-extra-bundle by using
  41. the DI\Service annotation.