Skip to content

Remove short factories/configurators examples #11589

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 29, 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
2 changes: 1 addition & 1 deletion doctrine/pdo_session_storage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
15 changes: 2 additions & 13 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
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

Expand Down Expand Up @@ -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.
18 changes: 2 additions & 16 deletions service_container/factories.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down