Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0d917b3

Browse files
implement ServiceSubscriberInterface where applicable
1 parent ffc93ea commit 0d917b3

File tree

8 files changed

+57
-23
lines changed

8 files changed

+57
-23
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,8 @@
4949

5050
<service id="session_listener" class="Symfony\Component\HttpKernel\EventListener\SessionListener">
5151
<tag name="kernel.event_subscriber" />
52-
<argument type="service">
53-
<service class="Symfony\Component\DependencyInjection\ServiceLocator">
54-
<tag name="container.service_locator" />
55-
<argument type="collection">
56-
<argument key="session" type="service" id="session" on-invalid="ignore" />
57-
</argument>
58-
</service>
59-
</argument>
52+
<tag name="container.service_subscriber" id="session" />
53+
<argument type="service" id="container" />
6054
</service>
6155

6256
<service id="session.save_listener" class="Symfony\Component\HttpKernel\EventListener\SaveSessionListener">

src/Symfony/Bundle/FrameworkBundle/Resources/config/test.xml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,8 @@
2222

2323
<service id="test.session.listener" class="Symfony\Component\HttpKernel\EventListener\TestSessionListener">
2424
<tag name="kernel.event_subscriber" />
25-
<argument type="service">
26-
<service class="Symfony\Component\DependencyInjection\ServiceLocator">
27-
<tag name="container.service_locator" />
28-
<argument type="collection">
29-
<argument key="session" type="service" id="session" on-invalid="ignore" />
30-
</argument>
31-
</service>
32-
</argument>
25+
<tag name="container.service_subscriber" id="session" />
26+
<argument type="service" id="container" />
3327
</service>
3428
</services>
3529
</container>

src/Symfony/Bundle/FrameworkBundle/Routing/Router.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Routing;
1313

14+
use Symfony\Component\Config\Loader\LoaderInterface;
1415
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
16+
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
1517
use Symfony\Component\Routing\Router as BaseRouter;
1618
use Symfony\Component\Routing\RequestContext;
1719
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -25,7 +27,7 @@
2527
*
2628
* @author Fabien Potencier <[email protected]>
2729
*/
28-
class Router extends BaseRouter implements WarmableInterface
30+
class Router extends BaseRouter implements WarmableInterface, ServiceSubscriberInterface
2931
{
3032
private $container;
3133
private $collectedParameters = array();
@@ -173,4 +175,14 @@ private function resolve($value)
173175

174176
return str_replace('%%', '%', $escapedValue);
175177
}
178+
179+
/**
180+
* {@inheritdoc}
181+
*/
182+
public static function getSubscribedServices()
183+
{
184+
return array(
185+
'routing.loader' => LoaderInterface::class,
186+
);
187+
}
176188
}

src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\TwigBundle\CacheWarmer;
1313

1414
use Psr\Container\ContainerInterface;
15+
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
1516
use Symfony\Component\Finder\Finder;
1617
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
1718
use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface;
@@ -25,7 +26,7 @@
2526
*
2627
* @author Fabien Potencier <[email protected]>
2728
*/
28-
class TemplateCacheCacheWarmer implements CacheWarmerInterface
29+
class TemplateCacheCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterface
2930
{
3031
protected $container;
3132
protected $finder;
@@ -92,6 +93,16 @@ public function isOptional()
9293
return true;
9394
}
9495

96+
/**
97+
* {@inheritdoc}
98+
*/
99+
public static function getSubscribedServices()
100+
{
101+
return array(
102+
'twig' => \Twig_Environment::class,
103+
);
104+
}
105+
95106
/**
96107
* Find templates in the given directory.
97108
*

src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727

2828
<service id="twig.cache_warmer" class="Symfony\Bundle\TwigBundle\CacheWarmer\TemplateCacheCacheWarmer" public="false">
2929
<tag name="kernel.cache_warmer" />
30-
<argument type="service" id="service_container" />
30+
<tag name="container.service_subscriber" id="twig" />
31+
<argument type="service" id="container" />
3132
<argument type="service" id="templating.finder" on-invalid="ignore" />
3233
<argument type="collection" /> <!-- Twig paths -->
3334
</service>

src/Symfony/Component/HttpKernel/CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ CHANGELOG
66

77
* added the possibility to change the query string parameter used by `UriSigner`
88
* deprecated `LazyLoadingFragmentHandler::addRendererService()`
9-
* added `SessionListener`
10-
* added `TestSessionListener`
119

1210
3.2.0
1311
-----

src/Symfony/Component/HttpKernel/EventListener/SessionListener.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
namespace Symfony\Component\HttpKernel\EventListener;
1313

1414
use Psr\Container\ContainerInterface;
15+
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
16+
use Symfony\Component\HttpFoundation\Session\SessionInterface;
1517

1618
/**
1719
* Sets the session in the request.
@@ -20,7 +22,7 @@
2022
*
2123
* @final since version 3.3
2224
*/
23-
class SessionListener extends AbstractSessionListener
25+
class SessionListener extends AbstractSessionListener implements ServiceSubscriberInterface
2426
{
2527
private $container;
2628

@@ -37,4 +39,14 @@ protected function getSession()
3739

3840
return $this->container->get('session');
3941
}
42+
43+
/**
44+
* {@inheritdoc}
45+
*/
46+
public static function getSubscribedServices()
47+
{
48+
return array(
49+
'session' => '?'.SessionInterface::class,
50+
);
51+
}
4052
}

src/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
namespace Symfony\Component\HttpKernel\EventListener;
1313

1414
use Psr\Container\ContainerInterface;
15+
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
16+
use Symfony\Component\HttpFoundation\Session\SessionInterface;
1517

1618
/**
1719
* Sets the session in the request.
@@ -20,7 +22,7 @@
2022
*
2123
* @final since version 3.3
2224
*/
23-
class TestSessionListener extends AbstractTestSessionListener
25+
class TestSessionListener extends AbstractTestSessionListener implements ServiceSubscriberInterface
2426
{
2527
private $container;
2628

@@ -37,4 +39,14 @@ protected function getSession()
3739

3840
return $this->container->get('session');
3941
}
42+
43+
/**
44+
* {@inheritdoc}
45+
*/
46+
public static function getSubscribedServices()
47+
{
48+
return array(
49+
'session' => '?'.SessionInterface::class,
50+
);
51+
}
4052
}

0 commit comments

Comments
 (0)