Skip to content

Adding a note about finding more examples of working with DI definitions #2162

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
Jan 20, 2013
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
12 changes: 9 additions & 3 deletions components/dependency_injection/definitions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Getting and Setting Service Definitions
There are also some helpful methods for
working with the service definitions.

To find out if there is a definition for a service id::
To find out if there is a definition for a service id::

$container->hasDefinition($serviceId);

Expand Down Expand Up @@ -84,7 +84,7 @@ To get an array of the constructor arguments for a definition you can use::

or to get a single argument by its position::

$definition->getArgument($index);
$definition->getArgument($index);
//e.g. $definition->getArguments(0) for the first argument

You can add a new argument to the end of the arguments array using::
Expand All @@ -95,7 +95,7 @@ The argument can be a string, an array, a service parameter by using ``%paramete
or a service id by using ::

use Symfony\Component\DependencyInjection\Reference;

// ...

$definition->addArgument(new Reference('service_id'));
Expand Down Expand Up @@ -131,3 +131,9 @@ You can also replace any existing method calls with an array of new ones with::

$definition->setMethodCalls($methodCalls);

.. tip::

There are more examples of specific ways of working with definitions
in the PHP code blocks of the configuration examples on pages such as
:doc:`/components/dependency_injection/factories` and
:doc:`/components/dependency_injection/parentservices`