forked from symfony/symfony-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 2.7: (23 commits) [symfony#5331] Tiny typo [symfony#5373] Small tweak per Stof's comment [PSR-7] Bridge documentation Fix after install URL and new photo since AcmeDemoBundle is not part of 2.7 Fixed a minor grammar issue Fixed typos Link to the official repository of the bundle. Added mentions to some popular (and useful) Symfony bundles [symfony#5095] Fixing a typo and updating to a more realistic example [Components][ClassLoader] remove DebugClassLoader [symfony#4228] Move synthetic services to its own recipe clarify bundle installation instructions Implemented the suggestions made by Christian and Wouter Replace phpDocumentor by the standard PHPDoc Implemented the changes suggested by reviewers Fixed an internal link reference Reviewed the Bundles cookbook articles Updated the list of reserved domains and the URL reference Use the reserved domains example.com and example.org Constraints - empty strings and null values ...
- Loading branch information
Showing
27 changed files
with
309 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
.. index:: | ||
single: ClassLoader; DebugClassLoader | ||
|
||
Debugging a Class Loader | ||
======================== | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
types | ||
parameters | ||
definitions | ||
synthetic_services | ||
compilation | ||
tags | ||
factories | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
.. index:: | ||
single: DependencyInjection; Synthetic Services | ||
|
||
How to Inject Instances into the Container | ||
------------------------------------------ | ||
|
||
When using the container in your application, you sometimes need to inject an | ||
instance instead of configuring the container to create a new instance. | ||
|
||
For instance, if you're using the :doc:`HttpKernel </components/http_kernel/introduction>` | ||
component with the DependencyInjection component, then the ``kernel`` | ||
service is injected into the container from within the ``Kernel`` class:: | ||
|
||
// ... | ||
abstract class Kernel implements KernelInterface, TerminableInterface | ||
{ | ||
// ... | ||
protected function initializeContainer() | ||
{ | ||
// ... | ||
$this->container->set('kernel', $this); | ||
|
||
// ... | ||
} | ||
} | ||
|
||
The ``kernel`` service is called a synthetic service. This service has to be | ||
configured in the container, so the container knows the service does exist | ||
during compilation (otherwise, services depending on this ``kernel`` service | ||
will get a "service does not exists" error). | ||
|
||
In order to do so, you have to use | ||
:method:`Definition::setSynthetic() <Symfony\\Component\\DependencyInjection\\Definition::setSynthetic>`:: | ||
|
||
use Symfony\Component\DependencyInjectino\Definition; | ||
|
||
// synthetic services don't specify a class | ||
$kernelDefinition = new Definition(); | ||
$kernelDefinition->setSynthetic(true); | ||
|
||
$container->setDefinition('your_service', $kernelDefinition); | ||
|
||
Now, you can inject the instance in the container using | ||
:method:`Container::set() <Symfony\\Component\\DependencyInjection\\Container::set>`:: | ||
|
||
$yourService = new YourObject(); | ||
$container->set('your_service', $yourService); | ||
|
||
``$container->get('your_service')`` will now return the same instance as | ||
``$yourService``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.