Skip to content

Added a reference to private aliases #7384

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

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 4 additions & 0 deletions service_container/alias_private.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,16 @@ services.
.. code-block:: php

use AppBundle\Mail\PhpMailer;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\Definition;

$container->setDefinition('app.phpmailer', new Definition(PhpMailer::class));

$containerBuilder->setAlias('app.mailer', 'app.phpmailer');

// private aliases are created passing 'false' to Alias() second argument
Copy link
Member

Choose a reason for hiding this comment

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

[...] as the second argument

$containerBuilder->setAlias('app.mailer', new Alias('app.phpmailer', false));

This means that when using the container directly, you can access the
Copy link
Contributor

@ogizanagi ogizanagi Jan 18, 2017

Choose a reason for hiding this comment

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

Given this explanation, I wonder if the above place is the right place to show this? (the alias won't be usable using $container->get(...) when private)

``app.phpmailer`` service by asking for the ``app.mailer`` service like this::

Expand Down