-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e94807
commit a2105d4
Showing
5 changed files
with
189 additions
and
37 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/Symfony/Component/DependencyInjection/Compiler/CompilerPassInterface.php
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,30 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
/* | ||
* This file is part of the Symfony framework. | ||
* | ||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
/** | ||
* Interface that must be implemented by compilation passes | ||
* | ||
* @author Johannes M. Schmitt <schmittjoh@gmail.com> | ||
*/ | ||
interface CompilerPassInterface | ||
{ | ||
/** | ||
* You can modify the container here before it is dumped to PHP code. | ||
* | ||
* @param ContainerBuilder $container | ||
* @return void | ||
*/ | ||
function process(ContainerBuilder $container); | ||
} |
51 changes: 51 additions & 0 deletions
51
src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php
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,51 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
/* | ||
* This file is part of the Symfony framework. | ||
* | ||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
/** | ||
* Merges extension configs into the container builder | ||
* | ||
* @author Fabien Potencier <fabien.potencier@symfony-project.com> | ||
*/ | ||
class MergeExtensionConfigurationPass implements CompilerPassInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
$parameters = $container->getParameterBag()->all(); | ||
$definitions = $container->getDefinitions(); | ||
$aliases = $container->getAliases(); | ||
|
||
foreach ($container->getExtensionConfigs() as $name => $configs) { | ||
list($namespace, $tag) = explode(':', $name); | ||
|
||
$extension = $container->getExtension($namespace); | ||
|
||
$tmpContainer = new ContainerBuilder($container->getParameterBag()); | ||
$tmpContainer->addObjectResource($extension); | ||
foreach ($configs as $config) { | ||
$extension->load($tag, $config, $tmpContainer); | ||
} | ||
|
||
$container->merge($tmpContainer); | ||
} | ||
|
||
$container->setExtensionConfigs(array()); | ||
$container->addDefinitions($definitions); | ||
$container->addAliases($aliases); | ||
$container->getParameterBag()->add($parameters); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/Symfony/Component/DependencyInjection/Compiler/ResolveInterfaceInjectorsPass.php
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,41 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
/* | ||
* This file is part of the Symfony framework. | ||
* | ||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
/** | ||
* Resolves interface injectors and inlines them as method calls | ||
* | ||
* @author Bulat Shakirzyanov <mallluhuct@gmail.com> | ||
*/ | ||
class ResolveInterfaceInjectorsPass implements CompilerPassInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
foreach ($container->getDefinitions() as $definition) { | ||
foreach ($container->getInterfaceInjectors() as $injector) { | ||
if (null !== $definition->getFactoryService()) { | ||
continue; | ||
} | ||
$defClass = $container->getParameterBag()->resolveValue($definition->getClass()); | ||
$definition->setClass($defClass); | ||
if ($injector->supports($defClass)) { | ||
$injector->processDefinition($definition); | ||
} | ||
} | ||
} | ||
} | ||
} |
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