Skip to content

Commit cf53d43

Browse files
committed
[TwigBundle] Deprecate the public "twig" service to private
1 parent 75e71e3 commit cf53d43

File tree

12 files changed

+115
-15
lines changed

12 files changed

+115
-15
lines changed

UPGRADE-5.2.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
UPGRADE FROM 5.1 to 5.2
2+
=======================
3+
4+
TwigBundle
5+
----------
6+
7+
* Deprecated the public `twig` service to private.

UPGRADE-6.0.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ Security
113113
* Removed `LogoutSuccessHandlerInterface` and `LogoutHandlerInterface`, register a listener on the `LogoutEvent` event instead.
114114
* Removed `DefaultLogoutSuccessHandler` in favor of `DefaultLogoutListener`.
115115

116+
TwigBundle
117+
----------
118+
119+
* The `twig` service is now private.
120+
116121
Yaml
117122
----
118123

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/BundlePathsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testBundlePublicDir()
4040
public function testBundleTwigTemplatesDir()
4141
{
4242
static::bootKernel(['test_case' => 'BundlePaths']);
43-
$twig = static::$container->get('twig');
43+
$twig = static::$container->get('twig.alias');
4444
$bundlesMetadata = static::$container->getParameter('kernel.bundles_metadata');
4545

4646
$this->assertSame([$bundlesMetadata['LegacyBundle']['path'].'/Resources/views'], $twig->getLoader()->getPaths('Legacy'));

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/BundlePaths/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ framework:
88

99
twig:
1010
strict_variables: '%kernel.debug%'
11+
12+
services:
13+
twig.alias:
14+
alias: twig
15+
public: true

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Controller/LoginController.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@
1111

1212
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Controller;
1313

14-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
15-
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
14+
use Psr\Container\ContainerInterface;
15+
use Symfony\Component\Form\FormFactoryInterface;
1616
use Symfony\Component\HttpFoundation\Response;
1717
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
18+
use Symfony\Contracts\Service\ServiceSubscriberInterface;
19+
use Twig\Environment;
1820

19-
class LoginController implements ContainerAwareInterface
21+
class LoginController implements ServiceSubscriberInterface
2022
{
21-
use ContainerAwareTrait;
23+
private $container;
24+
25+
public function __construct(ContainerInterface $container)
26+
{
27+
$this->container = $container;
28+
}
2229

2330
public function loginAction()
2431
{
@@ -43,4 +50,15 @@ public function secureAction()
4350
{
4451
throw new \Exception('Wrapper', 0, new \Exception('Another Wrapper', 0, new AccessDeniedException()));
4552
}
53+
54+
/**
55+
* {@inheritdoc}
56+
*/
57+
public static function getSubscribedServices()
58+
{
59+
return [
60+
'form.factory' => FormFactoryInterface::class,
61+
'twig' => Environment::class,
62+
];
63+
}
4664
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LocalizedController.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,21 @@
1111

1212
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\Controller;
1313

14-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
15-
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
14+
use Psr\Container\ContainerInterface;
1615
use Symfony\Component\HttpFoundation\Request;
1716
use Symfony\Component\HttpFoundation\Response;
1817
use Symfony\Component\Security\Core\Security;
18+
use Symfony\Contracts\Service\ServiceSubscriberInterface;
19+
use Twig\Environment;
1920

20-
class LocalizedController implements ContainerAwareInterface
21+
class LocalizedController implements ServiceSubscriberInterface
2122
{
22-
use ContainerAwareTrait;
23+
private $container;
24+
25+
public function __construct(ContainerInterface $container)
26+
{
27+
$this->container = $container;
28+
}
2329

2430
public function loginAction(Request $request)
2531
{
@@ -61,4 +67,14 @@ public function homepageAction()
6167
{
6268
return (new Response('<html><body>Homepage</body></html>'))->setPublic();
6369
}
70+
71+
/**
72+
* {@inheritdoc}
73+
*/
74+
public static function getSubscribedServices()
75+
{
76+
return [
77+
'twig' => Environment::class,
78+
];
79+
}
6480
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LoginController.php

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

1212
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\Controller;
1313

14-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
15-
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
14+
use Psr\Container\ContainerInterface;
1615
use Symfony\Component\HttpFoundation\Request;
1716
use Symfony\Component\HttpFoundation\Response;
1817
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
1918
use Symfony\Component\Security\Core\Security;
2019
use Symfony\Component\Security\Core\User\UserInterface;
20+
use Symfony\Contracts\Service\ServiceSubscriberInterface;
21+
use Twig\Environment;
2122

22-
class LoginController implements ContainerAwareInterface
23+
class LoginController implements ServiceSubscriberInterface
2324
{
24-
use ContainerAwareTrait;
25+
private $container;
26+
27+
public function __construct(ContainerInterface $container)
28+
{
29+
$this->container = $container;
30+
}
2531

2632
public function loginAction(Request $request, UserInterface $user = null)
2733
{
@@ -53,4 +59,14 @@ public function secureAction()
5359
{
5460
throw new \Exception('Wrapper', 0, new \Exception('Another Wrapper', 0, new AccessDeniedException()));
5561
}
62+
63+
/**
64+
* {@inheritdoc}
65+
*/
66+
public static function getSubscribedServices()
67+
{
68+
return [
69+
'twig' => Environment::class,
70+
];
71+
}
5672
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/FormLoginBundle.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,28 @@
1111

1212
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle;
1313

14+
use Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\Controller\LocalizedController;
15+
use Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\Controller\LoginController;
16+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1417
use Symfony\Component\HttpKernel\Bundle\Bundle;
1518

1619
class FormLoginBundle extends Bundle
1720
{
21+
/**
22+
* {@inheritdoc}
23+
*/
24+
public function build(ContainerBuilder $container)
25+
{
26+
parent::build($container);
27+
28+
$container
29+
->register(LoginController::class)
30+
->setPublic(true)
31+
->addTag('container.service_subscriber');
32+
33+
$container
34+
->register(LocalizedController::class)
35+
->setPublic(true)
36+
->addTag('container.service_subscriber');
37+
}
1838
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ services:
99
tags:
1010
- { name: form.type }
1111

12+
Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Controller\LoginController:
13+
public: true
14+
tags:
15+
- { name: container.service_subscriber }
16+
1217
security:
1318
encoders:
1419
Symfony\Component\Security\Core\User\User: plaintext

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+
5.2.0
5+
-----
6+
7+
* deprecated the public `twig` service to private
8+
49
5.0.0
510
-----
611

0 commit comments

Comments
 (0)