Skip to content

Removed the deprecated factory YAML config #11625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions service_container/configurators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
AppBundle\Mail\NewsletterManager:
configurator: 'AppBundle\Mail\EmailConfigurator:configure'
configurator: ['@AppBundle\Mail\EmailConfigurator', 'configure']

AppBundle\Mail\GreetingCardManager:
configurator: 'AppBundle\Mail\EmailConfigurator:configure'
configurator: ['@AppBundle\Mail\EmailConfigurator', 'configure']

.. code-block:: xml

Expand Down Expand Up @@ -184,22 +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']);

.. versionadded:: 3.2

The ``service_id:method_name`` syntax for the YAML configuration format
was introduced in Symfony 3.2.

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: 'AppBundle\Mail\EmailConfigurator:configure'
# old syntax
configurator: ['@AppBundle\Mail\EmailConfigurator', configure]

That's it! When requesting the ``AppBundle\Mail\NewsletterManager`` or
``AppBundle\Mail\GreetingCardManager`` service, the created instance will first be
passed to the ``EmailConfigurator::configure()`` method.
19 changes: 2 additions & 17 deletions service_container/factories.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ configure the service container to use the

AppBundle\Email\NewsletterManager:
# call the static method that creates the object
factory: ['AppBundle\Email\NewsletterManagerStaticFactory', createNewsletterManager]
factory: ['AppBundle\Email\NewsletterManagerStaticFactory', 'createNewsletterManager']
# define the class of the created object
class: AppBundle\Email\NewsletterManager

Expand Down Expand Up @@ -107,7 +107,7 @@ Configuration of the service container then looks like this:

AppBundle\Email\NewsletterManager:
# call a method on the specified factory service
factory: 'AppBundle\Email\NewsletterManagerFactory:createNewsletterManager'
factory: ['@AppBundle\Email\NewsletterManagerFactory', 'createNewsletterManager']
class: AppBundle\Email\NewsletterManager

.. code-block:: xml
Expand Down Expand Up @@ -150,21 +150,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

# app/config/services.yml
AppBundle\Email\NewsletterManager:
class: AppBundle\Email\NewsletterManager
# new syntax
factory: 'AppBundle\Email\NewsletterManagerFactory:createNewsletterManager'
# old syntax
factory: ['@AppBundle\Email\NewsletterManagerFactory', createNewsletterManager]

.. _factories-passing-arguments-factory-method:

Passing Arguments to the Factory Method
Expand Down