implement ServiceSubscriberInterface where applicable
This commit is contained in:
parent
9b7df39865
commit
c5e80a2b09
@ -53,14 +53,8 @@
|
||||
|
||||
<service id="session_listener" class="Symfony\Component\HttpKernel\EventListener\SessionListener">
|
||||
<tag name="kernel.event_subscriber" />
|
||||
<argument type="service">
|
||||
<service class="Symfony\Component\DependencyInjection\ServiceLocator">
|
||||
<tag name="container.service_locator" />
|
||||
<argument type="collection">
|
||||
<argument key="session" type="service" id="session" on-invalid="ignore" />
|
||||
</argument>
|
||||
</service>
|
||||
</argument>
|
||||
<tag name="container.service_subscriber" id="session" />
|
||||
<argument type="service" id="container" />
|
||||
</service>
|
||||
|
||||
<service id="session.save_listener" class="Symfony\Component\HttpKernel\EventListener\SaveSessionListener">
|
||||
|
@ -22,14 +22,8 @@
|
||||
|
||||
<service id="test.session.listener" class="Symfony\Component\HttpKernel\EventListener\TestSessionListener">
|
||||
<tag name="kernel.event_subscriber" />
|
||||
<argument type="service">
|
||||
<service class="Symfony\Component\DependencyInjection\ServiceLocator">
|
||||
<tag name="container.service_locator" />
|
||||
<argument type="collection">
|
||||
<argument key="session" type="service" id="session" on-invalid="ignore" />
|
||||
</argument>
|
||||
</service>
|
||||
</argument>
|
||||
<tag name="container.service_subscriber" id="session" />
|
||||
<argument type="service" id="container" />
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
||||
|
@ -11,7 +11,9 @@
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Routing;
|
||||
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
|
||||
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
|
||||
use Symfony\Component\Routing\Router as BaseRouter;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
@ -25,7 +27,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class Router extends BaseRouter implements WarmableInterface
|
||||
class Router extends BaseRouter implements WarmableInterface, ServiceSubscriberInterface
|
||||
{
|
||||
private $container;
|
||||
private $collectedParameters = array();
|
||||
@ -173,4 +175,14 @@ class Router extends BaseRouter implements WarmableInterface
|
||||
|
||||
return str_replace('%%', '%', $escapedValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSubscribedServices()
|
||||
{
|
||||
return array(
|
||||
'routing.loader' => LoaderInterface::class,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Bundle\TwigBundle\CacheWarmer;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface;
|
||||
@ -25,7 +26,7 @@ use Symfony\Component\Templating\TemplateReference;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class TemplateCacheCacheWarmer implements CacheWarmerInterface
|
||||
class TemplateCacheCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterface
|
||||
{
|
||||
protected $container;
|
||||
protected $finder;
|
||||
@ -92,6 +93,16 @@ class TemplateCacheCacheWarmer implements CacheWarmerInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSubscribedServices()
|
||||
{
|
||||
return array(
|
||||
'twig' => \Twig_Environment::class,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find templates in the given directory.
|
||||
*
|
||||
|
@ -28,7 +28,8 @@
|
||||
|
||||
<service id="twig.cache_warmer" class="Symfony\Bundle\TwigBundle\CacheWarmer\TemplateCacheCacheWarmer" public="false">
|
||||
<tag name="kernel.cache_warmer" />
|
||||
<argument type="service" id="service_container" />
|
||||
<tag name="container.service_subscriber" id="twig" />
|
||||
<argument type="service" id="container" />
|
||||
<argument type="service" id="templating.finder" on-invalid="ignore" />
|
||||
<argument type="collection" /> <!-- Twig paths -->
|
||||
</service>
|
||||
|
@ -8,8 +8,6 @@ CHANGELOG
|
||||
* Deprecated the special `SYMFONY__` environment variables
|
||||
* added the possibility to change the query string parameter used by `UriSigner`
|
||||
* deprecated `LazyLoadingFragmentHandler::addRendererService()`
|
||||
* added `SessionListener`
|
||||
* added `TestSessionListener`
|
||||
|
||||
3.2.0
|
||||
-----
|
||||
|
@ -12,6 +12,8 @@
|
||||
namespace Symfony\Component\HttpKernel\EventListener;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
|
||||
/**
|
||||
* Sets the session in the request.
|
||||
@ -20,7 +22,7 @@ use Psr\Container\ContainerInterface;
|
||||
*
|
||||
* @final since version 3.3
|
||||
*/
|
||||
class SessionListener extends AbstractSessionListener
|
||||
class SessionListener extends AbstractSessionListener implements ServiceSubscriberInterface
|
||||
{
|
||||
private $container;
|
||||
|
||||
@ -37,4 +39,14 @@ class SessionListener extends AbstractSessionListener
|
||||
|
||||
return $this->container->get('session');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSubscribedServices()
|
||||
{
|
||||
return array(
|
||||
'session' => '?'.SessionInterface::class,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,8 @@
|
||||
namespace Symfony\Component\HttpKernel\EventListener;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
|
||||
/**
|
||||
* Sets the session in the request.
|
||||
@ -20,7 +22,7 @@ use Psr\Container\ContainerInterface;
|
||||
*
|
||||
* @final since version 3.3
|
||||
*/
|
||||
class TestSessionListener extends AbstractTestSessionListener
|
||||
class TestSessionListener extends AbstractTestSessionListener implements ServiceSubscriberInterface
|
||||
{
|
||||
private $container;
|
||||
|
||||
@ -37,4 +39,14 @@ class TestSessionListener extends AbstractTestSessionListener
|
||||
|
||||
return $this->container->get('session');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSubscribedServices()
|
||||
{
|
||||
return array(
|
||||
'session' => '?'.SessionInterface::class,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user