From f98fa24c22e1abf385b09bad7fd6eb6c43fcf4dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Fri, 4 Oct 2013 15:04:11 +0200 Subject: [PATCH] Register Commands in the Service Container --- cookbook/console/console_command.rst | 46 ++++++++++++++++++++++++++++ reference/dic_tags.rst | 14 +++++++++ 2 files changed, 60 insertions(+) diff --git a/cookbook/console/console_command.rst b/cookbook/console/console_command.rst index 83033761feb..da6ff969200 100644 --- a/cookbook/console/console_command.rst +++ b/cookbook/console/console_command.rst @@ -62,6 +62,52 @@ This command will now automatically be available to run: $ app/console demo:greet Fabien +.. _cookbook-console-dic: + +Register Commands in the Service Container +------------------------------------------ + +.. versionadded:: 2.4 + Support for registering commands in the service container was added in + version 2.4. + +You can register commands in the service container using the ``console.command`` +tag: + +.. configuration-block:: + + .. code-block:: yaml + + # app/config/config.yml + services: + acme_hello.command.my_command: + class: Acme\HelloBundle\Command\MyCommand + tags: + - { name: console.command } + + .. code-block:: xml + + + + + + + + + + + .. code-block:: php + + // app/config/config.php + + $container + ->register('acme_hello.command.my_command', 'Acme\HelloBundle\Command\MyCommand') + ->addTag('console.command') + ; + Getting Services from the Service Container ------------------------------------------- diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index 727ef309f2d..731cfd84454 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -29,6 +29,8 @@ may also be tags in other bundles you use that aren't listed here. +-----------------------------------+---------------------------------------------------------------------------+ | `assetic.templating.twig`_ | Remove this service if twig templating is disabled | +-----------------------------------+---------------------------------------------------------------------------+ +| `console.command`_ | Add a command | ++-----------------------------------+---------------------------------------------------------------------------+ | `data_collector`_ | Create a class that collects custom data for the profiler | +-----------------------------------+---------------------------------------------------------------------------+ | `doctrine.event_listener`_ | Add a Doctrine event listener | @@ -241,6 +243,18 @@ assetic.templating.twig The tagged service will be removed from the container if ``framework.templating.engines`` config section does not contain twig. +console.command +--------------- + +.. versionadded:: 2.4 + Support for registering commands in the service container was added in + version 2.4. + +**Purpose**: Add a command to the application + +For details on registering your own commands in the service container, read +:ref:`the cookbook article`. + data_collector --------------