c5f2ec8d2d
Now that we have a compilation phase for the DIC, using tags after compilation is not needed anymore. Tags were introduced to allow several independant bundles to be able to interact which each others (remember that each extension knows nothing about the others). But during the compilation phase, the container has been merged ans so, all the information from all bundles are available. This is then the right place to deal with tags. That way, less work is needed at runtime and the DIC class in the cache is also much smaller. For simple cases, it means that you need to process the tag in a compiler pass and store the information you need in a DIC parameter (have a look at the TranslatorPass for a very simple example). So, the PHP dumper does not add tags to the dumped PHP class anymore (it does not implements TaggedContainerInterface anymore). But tags are still available on ContainerBuilder instances.
67 lines
1.7 KiB
PHP
Executable File
67 lines
1.7 KiB
PHP
Executable File
<?php
|
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
use Symfony\Component\DependencyInjection\Container;
|
|
use Symfony\Component\DependencyInjection\Reference;
|
|
use Symfony\Component\DependencyInjection\Parameter;
|
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
|
|
|
/**
|
|
* ProjectServiceContainer
|
|
*
|
|
* This class has been auto-generated
|
|
* by the Symfony Dependency Injection Component.
|
|
*/
|
|
class ProjectServiceContainer extends Container
|
|
{
|
|
/**
|
|
* Constructor.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct(new ParameterBag($this->getDefaultParameters()));
|
|
}
|
|
|
|
/**
|
|
* Gets the 'barfactory' service.
|
|
*
|
|
* This service is shared.
|
|
* This method always returns the same instance of the service.
|
|
*
|
|
* @return BarClassFactory A BarClassFactory instance.
|
|
*/
|
|
protected function getBarfactoryService()
|
|
{
|
|
return $this->services['barfactory'] = new \BarClassFactory();
|
|
|
|
$this->applyInterfaceInjectors($instance);
|
|
}
|
|
|
|
/**
|
|
* Gets the 'bar' service.
|
|
*
|
|
* This service is shared.
|
|
* This method always returns the same instance of the service.
|
|
*
|
|
* @return Object An instance returned by barFactory::createBarClass().
|
|
*/
|
|
protected function getBarService()
|
|
{
|
|
return $this->services['bar'] = $this->get('barFactory')->createBarClass();
|
|
|
|
$this->applyInterfaceInjectors($instance);
|
|
}
|
|
|
|
/**
|
|
* Applies all known interface injection calls
|
|
*
|
|
* @param Object $instance
|
|
*/
|
|
protected function applyInterfaceInjectors($instance)
|
|
{
|
|
if ($instance instanceof \BarClass) {
|
|
$instance->setFoo('someValue');
|
|
}
|
|
}
|
|
}
|