8000 Replace some container injections by service locators · Deamon/symfony@8293b75 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8293b75

Browse files
committed
Replace some container injections by service locators
1 parent 0be9ea8 commit 8293b75

25 files changed

+298
-140
lines changed

UPGRADE-3.3.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,22 @@ FrameworkBundle
7171
deprecated and will be removed in 4.0. Use the `Symfony\Component\Form\DependencyInjection\FormPass`
7272
class instead.
7373

74+
* The `Symfony\Bundle\FrameworkBundle\EventListener\SessionListener` class has been
75+
deprecated and will be removed in 4.0. Use the `Symfony\Component\HttpKernel\EventListener\SessionListener`
76+
class instead.
77+
78+
* The `Symfony\Bundle\FrameworkBundle\EventListener\TestSessionListener` class has been
79+
deprecated and will be removed in 4.0. Use the `Symfony\Component\HttpKernel\EventListener\TestSessionListener`
80+
class instead.
81+
7482
HttpKernel
7583
-----------
7684

7785
* The `Psr6CacheClearer::addPool()` method has been deprecated. Pass an array of pools indexed
7886
by name to the constructor instead.
87+
88+
* The `LazyLoadingFragmentHandler::addRendererService()` method has been deprecated and
89+
will be removed in 4.0.
7990

8091
Process
8192
-------
@@ -127,6 +138,12 @@ TwigBridge
127138
* The `TwigRendererEngine::setEnvironment()` method has been deprecated and will be removed
128139
in 4.0. Pass the Twig Environment as second argument of the constructor instead.
129140

141+
TwigBundle
142+
----------
143+
144+
* The `ContainerAwareRuntimeLoader` class has been deprecated and will be removed in 4.0.
145+
Use the Twig `Twig_ContainerRuntimeLoader` class instead.
146+
130147
Workflow
131148
--------
132149

UPGRADE-4.0.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ FrameworkBundle
188188
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FormPass` class has been
189189
removed. Use the `Symfony\Component\Form\DependencyInjection\FormPass` class instead.
190190

191+
* The `Symfony\Bundle\FrameworkBundle\EventListener\SessionListener` class has been removed.
192+
Use the `Symfony\Component\HttpKernel\EventListener\SessionListener` class instead.
193+
194+
* The `Symfony\Bundle\FrameworkBundle\EventListener\TestSessionListener` class has been
195+
removed. Use the `Symfony\Component\HttpKernel\EventListener\TestSessionListener`
196+
class instead.
197+
191198
HttpFoundation
192199
---------------
193200

@@ -229,6 +236,8 @@ HttpKernel
229236

230237
* The `Psr6CacheClearer::addPool()` method has been removed. Pass an array of pools indexed
231238
by name to the constructor instead.
239+
240+
* The `LazyLoadingFragmentHandler::addRendererService()` method has been removed.
232241

233242
Ldap
234243
----
@@ -285,6 +294,12 @@ Translation
285294

286295
* Removed the backup feature from the file dumper classes.
287296

297+
TwigBundle
298+
----------
299+
300+
* The `ContainerAwareRuntimeLoader` class has been removed. Use the
301+
Twig `Twig_ContainerRuntimeLoader` class instead.
302+
288303
TwigBridge
289304
----------
290305

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ CHANGELOG
1515
* Added configurable paths for validation files
1616
* Deprecated `SerializerPass`, use `Symfony\Component\Serializer\DependencyInjection\SerializerPass` instead
1717
* Deprecated `FormPass`, use `Symfony\Component\Form\DependencyInjection\FormPass` instead
18+
* Deprecated `SessionListener`
19+
* Deprecated `TestSessionListener`
1820

1921
3.2.0
2022
-----

src/Symfony/Bundle/FrameworkBundle/EventListener/SessionListener.php

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,16 @@
1212
namespace Symfony\Bundle\FrameworkBundle\EventListener;
1313

1414
use Symfony\Component\HttpKernel\EventListener\SessionListener as BaseSessionListener;
15-
use Symfony\Component\DependencyInjection\ContainerInterface;
15+
16+
@trigger_error(sprintf('The %s class is deprecated since version 3.3 and will be removed in 4.0. Use %s instead.', SessionListener::class, BaseSessionListener::class), E_USER_DEPRECATED);
1617

1718
/**
1819
* Sets the session in the request.
1920
*
2021
* @author Fabien Potencier <fabien@symfony.com>
22+
*
23+
* @deprecated since version 3.3, to be removed in 4.0. Use {@link BaseSessionListener} instead
2124
*/
2225
class SessionListener extends BaseSessionListener
2326
{
24-
/**
25-
* @var ContainerInterface
26-
*/
27-
private $container;
28-
29-
public function __construct(ContainerInterface $container)
30-
{
31-
$this->container = $container;
32-
}
33-
34-
protected function getSession()
35-
{
36-
if (!$this->container->has('session')) {
37-
return;
38-
}
39-
40-
return $this->container->get('session');
41-
}
4227
}

src/Symfony/Bundle/FrameworkBundle/EventListener/TestSessionListener.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\EventListener;
1313

14-
use Symfony\Component\HttpKernel\EventListener\TestSessionListener as BaseTestSessionListener;
14+
@trigger_error(sprintf('The %s class is deprecated since version 3.3 and will be removed in 4.0. Use Symfony\Component\HttpKernel\EventListener\TestSessionListener instead.', TestSessionListener::class), E_USER_DEPRECATED);
15+
16+
use Symfony\Component\HttpKernel\EventListener\AbstractTestSessionListener;
1517
use Symfony\Component\DependencyInjection\ContainerInterface;
1618

1719
/**
1820
* TestSessionListener.
1921
*
2022
* @author Fabien Potencier <fabien@symfony.com>
23+
*
24+
* @deprecated since version 3.3, to be removed in 4.0.
2125
*/
22-
class TestSessionListener extends BaseTestSessionListener
26+
class TestSessionListener extends AbstractTestSessionListener
2327
{
2428
protected $container;
2529

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

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

1212
<services>
1313
<service id="fragment.handler" class="Symfony\Component\HttpKernel\DependencyInjection\LazyLoadingFragmentHandler">
14-
<argument type="service" id="service_container" />
14+
<argument /> <!-- fragment renderer locator -->
1515
<argument type="service" id="request_stack" />
1616
<argument>%kernel.debug%</argument>
1717
</service>

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@
4747

4848
<service id="session.handler.write_check" class="Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler" public="false" />
4949

50-
<service id="session_listener" class="Symfony\Bundle\FrameworkBundle\EventListener\SessionListener">
50+
<service id="session_listener" class="Symfony\Component\HttpKernel\EventListener\SessionListener">
5151
<tag name="kernel.event_subscriber" />
52-
<argument type="service" id="service_container" />
52+
<argument type="service-locator">
53+
<argument key="session" type="service" id="session" on-invalid="null" />
54+
</argument>
5355
</service>
5456

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

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020

2121
<service id="test.client.cookiejar" class="Symfony\Component\BrowserKit\CookieJar" shared="false" />
2222

23-
<service id="test.session.listener" class="Symfony\Bundle\FrameworkBundle\EventListener\TestSessionListener">
24-
<argument type="service" id="service_container" />
23+
<service id="test.session.listener" class="Symfony\Component\HttpKernel\EventListener\TestSessionListener">
2524
<tag name="kernel.event_subscriber" />
25+
<argument type="service-locator">
26+
<argument key="session" type="service" id="session" on-invalid="null" />
27+
</argument>
2628
</service>
2729
</services>
2830
</container>

src/Symfony/Bundle/TwigBundle/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
3.3.0
5+
-----
6+
7+
* Deprecated `ContainerAwareRuntimeLoader`
8+
49
2.7.0
510
-----
611

src/Symfony/Bundle/TwigBundle/ContainerAwareRuntimeLoader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@
1111

1212
namespace Symfony\Bundle\TwigBundle;
1313

14+
@trigger_error(sprintf('The %s class is deprecated since version 3.3 and will be removed in 4.0. Use the Twig_ContainerRuntimeLoader class instead.'), ContainerAwareRuntimeLoader::class);
15+
1416
use Psr\Log\LoggerInterface;
1517
use Symfony\Component\DependencyInjection\ContainerInterface;
1618

1719
/**
1820
* Loads Twig extension runtimes via the service container.
1921
*
2022
* @author Fabien Potencier <fabien@symfony.com>
23+
*
24+
* @deprecated since version 3.3, will be removed in 4.0. Use \Twig_ContainerRuntimeLoader instead.
2125
*/
2226
class ContainerAwareRuntimeLoader implements \Twig_RuntimeLoaderInterface
2327
{

0 commit comments

Comments
 (0)
0