Skip to content

[DependencyInjection] Update service_container.rst #19076

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
Oct 23, 2023
Merged
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
10 changes: 5 additions & 5 deletions service_container.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,7 @@ You also have a service that defines many methods and one of them is the same
{
// other methods...

public function format($string $message, array $parameters): string
public function format(string $message, array $parameters): string
{
// ...
}
Expand All @@ -1438,7 +1438,7 @@ Thanks to the ``#[AutowireCallable]`` attribute, you can now inject this
class Mailer
{
public function __construct(
#[AutowireCallable(service: MessageUtils::class, method: 'formatMessage')]
#[AutowireCallable(service: MessageUtils::class, method: 'format')]
private MessageFormatterInterface $formatter
) {
}
Expand Down Expand Up @@ -1470,7 +1470,7 @@ an adapter for a functional interface through configuration:

app.message_formatter:
class: App\Service\MessageFormatterInterface
from_callable: [!service {class: 'App\Service\MessageUtils'}, 'formatMessage']
from_callable: [!service {class: 'App\Service\MessageUtils'}, 'format']

.. code-block:: xml

Expand All @@ -1485,7 +1485,7 @@ an adapter for a functional interface through configuration:
<!-- ... -->

<service id="app.message_formatter" class="App\Service\MessageFormatterInterface">
<from-callable method="formatMessage">
<from-callable method="format">
<service class="App\Service\MessageUtils"/>
</from-callable>
</service>
Expand All @@ -1506,7 +1506,7 @@ an adapter for a functional interface through configuration:

$container
->set('app.message_formatter', MessageFormatterInterface::class)
->fromCallable([inline_service(MessageUtils::class), 'formatMessage'])
->fromCallable([inline_service(MessageUtils::class), 'format'])
->alias(MessageFormatterInterface::class, 'app.message_formatter')
;
};
Expand Down