From e8cfa6e1afd82f68fe4ce83183226245fb21d79d Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 21 May 2019 18:19:02 +0200 Subject: [PATCH] Remove short factories/configurators examples --- doctrine/pdo_session_storage.rst | 2 +- service_container/configurators.rst | 15 ++------------- service_container/factories.rst | 18 ++---------------- 3 files changed, 5 insertions(+), 30 deletions(-) diff --git a/doctrine/pdo_session_storage.rst b/doctrine/pdo_session_storage.rst index 4c94d061408..1b14a7d8fee 100644 --- a/doctrine/pdo_session_storage.rst +++ b/doctrine/pdo_session_storage.rst @@ -28,7 +28,7 @@ To use it, first register a new handler service: # If you're using Doctrine & want to re-use that connection, then: # comment-out the above 2 lines and uncomment the line below - # - !service { class: PDO, factory: 'database_connection:getWrappedConnection' } + # - !service { class: PDO, factory: ['@database_connection', getWrappedConnection] } # If you get transaction issues (e.g. after login) uncomment the line below # - { lock_mode: 1 } diff --git a/service_container/configurators.rst b/service_container/configurators.rst index 4287b9ba24d..04babcb5d36 100644 --- a/service_container/configurators.rst +++ b/service_container/configurators.rst @@ -136,10 +136,10 @@ all the classes are already loaded as services. All you need to do is specify th # override the services to set the configurator App\Mail\NewsletterManager: - configurator: 'App\Mail\EmailConfigurator:configure' + configurator: ['@App\Mail\EmailConfigurator', configure] App\Mail\GreetingCardManager: - configurator: 'App\Mail\EmailConfigurator:configure' + configurator: ['@App\Mail\EmailConfigurator', configure] .. code-block:: xml @@ -184,17 +184,6 @@ all the classes are already loaded as services. All you need to do is specify th $container->getDefinition(GreetingCardManager::class) ->setConfigurator([new Reference(EmailConfigurator::class), 'configure']); -The traditional configurator syntax in YAML files used an array to define -the service id and the method name: - -.. code-block:: yaml - - app.newsletter_manager: - # new syntax - configurator: 'App\Mail\EmailConfigurator:configure' - # old syntax - configurator: ['@App\Mail\EmailConfigurator', configure] - That's it! When requesting the ``App\Mail\NewsletterManager`` or ``App\Mail\GreetingCardManager`` service, the created instance will first be passed to the ``EmailConfigurator::configure()`` method. diff --git a/service_container/factories.rst b/service_container/factories.rst index 0662cc1ff02..7e2c5f85d9d 100644 --- a/service_container/factories.rst +++ b/service_container/factories.rst @@ -104,7 +104,7 @@ Configuration of the service container then looks like this: App\Email\NewsletterManager: # call a method on the specified factory service - factory: 'App\Email\NewsletterManagerFactory:createNewsletterManager' + factory: ['@App\Email\NewsletterManagerFactory', createNewsletterManager] .. code-block:: xml @@ -144,20 +144,6 @@ Configuration of the service container then looks like this: 'createNewsletterManager', ]); -.. note:: - - The traditional configuration syntax in YAML files used an array to define - the factory service and the method name: - - .. code-block:: yaml - - # config/services.yaml - App\Email\NewsletterManager: - # new syntax - factory: 'App\Email\NewsletterManagerFactory:createNewsletterManager' - # old syntax - factory: ['@App\Email\NewsletterManagerFactory', createNewsletterManager] - .. _factories-passing-arguments-factory-method: Passing Arguments to the Factory Method @@ -181,7 +167,7 @@ example takes the ``templating`` service as an argument: # ... App\Email\NewsletterManager: - factory: 'App\Email\NewsletterManagerFactory:createNewsletterManager' + factory: ['@App\Email\NewsletterManagerFactory', createNewsletterManager] arguments: ['@templating'] .. code-block:: xml