Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
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
28 changes: 14 additions & 14 deletions guides/v1.0/config-guide/config/depend-inj.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ See one of the following sections:
* <a href="#dep-inj-mod">Configuration overview</a>
* <a href="#dep-inj-mod-class">Class definitions</a>
* <a href="#dep-inj-mod-type">Type configurations</a>
* <a href="#dep-inj-mod-type-life-mgmt">Lifestyle management</a>
* <a href="#dep-inj-mod-type-life-mgmt">Lifecycle management</a>
* <a href="#dep-inj-compile">Definition compiler tool</a>

<h2 id="dep-inj-intro">Overview of dependency injection</h2>
Expand Down Expand Up @@ -57,9 +57,9 @@ Proxy
: Auto-generated object that implements the same interface as the original object, but unlike this original object has only one dependency&mdash;the object manager. A proxy is used for lazy loading of optional dependencies.


Lifestyle
Lifecycle

: An object's *lifestyle* determines in what scope instances are reused, and when to release them. For more information, see <a href="http://docs.castleproject.org/%28X%281%29S%283i1uai55lunseee55whzgdzv%29%29/Default.aspx?Page=LifeStyles&NS=Windsor&AspxAutoDetectCookieSupport=1" target="_blank">the Castle project</a>.
: An object's *lifecycle* determines in what scope instances are reused, and when to release them.

<h2 id="dep-inj-preview">Preview of using dependency injection</h2>
This section provides examples of constructor and method injection so you can see what they look at. To use dependency injection in your module, you must configure it as discussed in <a href="#dep-inj-mod">Configuration overview</a>.
Expand Down Expand Up @@ -147,7 +147,7 @@ class Builder
The object manager needs the following configurations:

* Class definitions for retrieving the types and numbers of class dependencies
* Instance configurations for retrieving how the objects are instantiated and for defining their lifestyle
* Instance configurations for retrieving how the objects are instantiated and for defining their lifecycle
* Abstraction-implementation mappings (that is, interface preferences) for defining what implementation is to be used upon request to an interface

To define the interface preferences for the object manager, use `app/etc/di/*.xml`, `<your module dir>/etc/<areaname>/di.xml`, and `<your module dir>/etc/di.xml` files depending on the level.
Expand Down Expand Up @@ -232,13 +232,13 @@ Sample argument that creates instances of `Magento\Core\Model\Session` with the
<th>Possible values</th>
</tr>
<tr>
<td><p><strong>Object with default lifestyle</strong></p>
<td><p><strong>Object with default lifecycle</strong></p>
<pre>&lt;argument xsi:type="object">
{Type_Name}&lt;/argument></pre>
<p><strong>Object with specified lifestyle</strong></p>
<p><strong>Object with specified lifecycle</strong></p>
<pre>&lt;argument xsi:type="object"
shared="{shared}">{Type_Name}&lt;/argument></pre></td>
<td>Creates an instance of <code>Type_Name</code> type and passed as argument. Any class name, interface name, or virtual type name can be passed as <code>Type_Name</code>. <code>shared</code> defines the lifestyle of a created instance. </td>
<td>Creates an instance of <code>Type_Name</code> type and passed as argument. Any class name, interface name, or virtual type name can be passed as <code>Type_Name</code>. <code>shared</code> defines the lifecycle of a created instance. </td>
<td>n/a</td>
</tr>
</tbody>
Expand Down Expand Up @@ -445,18 +445,18 @@ Parameters configured for a class type are automatically configured for all of i
</div>
</div>

<h2 id="dep-inj-mod-type-life-mgmt">Lifestyle management</h2>
An object's *lifestyle* determines in what scope instances are reused, and when to release them. For more information, see <a href="http://docs.castleproject.org/%28X%281%29S%283i1uai55lunseee55whzgdzv%29%29/Default.aspx?Page=LifeStyles&NS=Windsor&AspxAutoDetectCookieSupport=1" target="_blank">the Castle project</a>.
<h2 id="dep-inj-mod-type-life-mgmt">Lifecycle management</h2>
An object's *lifecycle* determines in what scope instances are reused, and when to release them.

The object manager creates objects and manages the lifestyle of the following types of objects:
The object manager creates objects and manages the lifecycle of the following types of objects:

* `singleton`&mdash;Create one class instance at the first request and subsequently reuse that instance. Release the instance when the container with which it's registered is disposed. This is the default.
* `transient`&mdash;Create a new class instance every time the class is requested.

The preceding lifestyles can be configured as:
The preceding lifecycle can be configured as:

* `argument`&mdash;Defines the lifestyle for the argument only.
* `type`&mdash;A convenience configuration that defines the lifestyle for all instances of the specified type.
* `argument`&mdash;Defines the lifecycle for the argument only.
* `type`&mdash;A convenience configuration that defines the lifecycle for all instances of the specified type.

<h3 id="dep-inj-mod-type-inject">Injectables and non-injectables</h3>
We use the following terms to describe objects that can or cannot be instantiated by the object manager:
Expand All @@ -469,7 +469,7 @@ Non-injectable

: Object that *cannot* be instantiated by the object manager. Typically, this object:

* Has a transient lifestyle
* Has a transient lifecycle
* Requires external (such as data user input or data from database) to be properly created

Most models are non-injectable (for example, <a href="{{ site.mage2000url }}app/code/Magento/Catalog/Model/Product.php" target="_blank">Magento\Catalog\Model\Product</a> or <a href="{{ site.mage2000url }}app/code/Magento/User/Model/User.php" target="_blank">Magento\User\Model\User</a>).
Expand Down