Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add section about anonymous services#9909

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
codedmonkey wants to merge1 commit intosymfony:2.8fromcodedmonkey:fix_5854
Closed
Changes fromall 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
36 changes: 36 additions & 0 deletionsservice_container/alias_private.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -129,6 +129,42 @@ This means that when using the container directly, you can access the
# ...
app.mailer: '@app.phpmailer'

Anonymous Services
--------------------

.. note::

Anonymous services are currently only supported by the XML configuration format.

In some cases, you may want to limit access to a service outside of its
intended scope. This is useful when you want to prevent other services from
using the service as their own dependency. This can be achieved by creating an
*anonymous service*.

For Symfony, an anonymous service is nothing more than a service without a
identifying name which is defined directly in its use context. The following
example shows how an anonymous service can be injected into another service:

.. configuration-block::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

we don't need theconfiguration-block here when we only have one config format

HeahDude reacted with thumbs up emoji

.. code-block:: xml

<!-- app/config/services.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="foo" class="AppBundle\Foo">
<argument type="service">
<service class="AppBundle\AnonymousBar" />
</argument>
</service>
</services>
</container>

Deprecating Services
--------------------

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp