console.rst 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. Console/Command-Line Commands
  2. =============================
  3. SonataAdminBundle provides the following console commands:
  4. * ``cache:create-cache-class``
  5. * ``sonata:admin:generate``
  6. * ``sonata:admin:list``
  7. * ``sonata:admin:explain``
  8. * ``sonata:admin:setup-acl``
  9. * ``sonata:admin:generate-object-acl``
  10. cache:create-cache-class
  11. ------------------------
  12. The ``cache:create-cache-class`` command generates the cache class
  13. (``app/cache/...env.../classes.php``) from the classes.map file.
  14. Usage example:
  15. .. code-block:: bash
  16. $ php app/console cache:create-cache-class
  17. sonata:admin:generate
  18. ---------------------
  19. The ``sonata:admin:generate`` command generates a new Admin class based on the given model
  20. class, registers it as a service and potentially creates a new controller.
  21. As an argument you need to specify the fully qualified model class.
  22. All passed arguments and options are used as default values in interactive mode.
  23. You can disable the interactive mode with ``--no-interaction`` option.
  24. The command require the SensioGeneratorBundle_ to work. If you don't already have it, you can install it with :
  25. .. code-block:: bash
  26. $ composer require --dev sensio/generator-bundle
  27. =============== ===============================================================================================================================
  28. Options Description
  29. =============== ===============================================================================================================================
  30. **bundle** the bundle name (the default value is determined by the given model class, e.g. "AppBundle" or "YourNSFooBundle")
  31. **admin** the admin class basename (by default this adds "Admin" to the model class name, e.g. "BarAdmin")
  32. **controller** the controller class basename (by default this adds "AdminController" to the model class name, e.g. "BarAdminController")
  33. **manager** the model manager type (by default this is the first registered model manager type, e.g. "orm")
  34. **services** the services YAML file (the default value is "services.yml" or "admin.yml" if it already exist)
  35. **id** the admin service ID (the default value is combination of the bundle name and admin class basename like "your_ns_foo.admin.bar")
  36. =============== ===============================================================================================================================
  37. Usage example:
  38. .. code-block:: bash
  39. $ php app/console sonata:admin:generate AppBundle/Entity/Foo
  40. sonata:admin:list
  41. -----------------
  42. To see which admin services are available use the ``sonata:admin:list`` command.
  43. It prints all the admin service ids available in your application. This command
  44. gets the ids from the ``sonata.admin.pool`` service where all the available admin
  45. services are registered.
  46. Usage example:
  47. .. code-block:: bash
  48. $ php app/console sonata:admin:list
  49. .. figure:: ../images/console_admin_list.png
  50. :align: center
  51. :alt: List command
  52. :width: 700px
  53. List command
  54. sonata:admin:explain
  55. --------------------
  56. The ``sonata:admin:explain`` command prints details about the admin of a model.
  57. As an argument you need to specify the admin service id of the Admin to explain.
  58. Usage example:
  59. .. code-block:: bash
  60. $ php app/console sonata:admin:explain sonata.news.admin.post
  61. .. figure:: ../images/console_admin_explain.png
  62. :align: center
  63. :alt: Explain command
  64. :width: 700px
  65. Explain command
  66. sonata:admin:setup-acl
  67. ----------------------
  68. The ``sonata:admin:setup-acl`` command updates ACL definitions for all Admin
  69. classes available in ``sonata.admin.pool``. For instance, every time you create a
  70. new ``Admin`` class, you can create its ACL by using the ``sonata:admin:setup-acl``
  71. command. The ACL database will be automatically updated with the latest masks
  72. and roles.
  73. Usage example:
  74. .. code-block:: bash
  75. $ php app/console sonata:admin:setup-acl
  76. sonata:admin:generate-object-acl
  77. --------------------------------
  78. The ``sonata:admin:generate-object-acl`` is an interactive command which helps
  79. you to generate ACL entities for the objects handled by your Admins. See the help
  80. of the command for more information.
  81. .. _SensioGeneratorBundle: http://symfony.com/doc/current/bundles/SensioGeneratorBundle/index.html