8000 [Templating] added more deprecation · symfony/symfony@715b7d9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 715b7d9

Browse files
committed
[Templating] added more deprecation
1 parent 224c891 commit 715b7d9

File tree

11 files changed

+50
-16
lines changed

11 files changed

+50
-16
lines changed

src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder;
3333
use Symfony\Component\Security\Core\User\UserProviderInterface;
3434
use Symfony\Component\Security\Http\Controller\UserValueResolver;
35+
use Symfony\Component\Templating\PhpEngine;
3536

3637
/**
3738
* SecurityExtension.
@@ -97,7 +98,9 @@ public function load(array $configs, ContainerBuilder $container)
9798
$loader->load('security.xml');
9899
$loader->load('security_listeners.xml');
99100
$loader->load('security_rememberme.xml');
100-
$loader->load('templating_php.xml');
101+
if (class_exists(PhpEngine::class)) {
102+
$loader->load('templating_php.xml');
103+
}
101104
$loader->load('templating_twig.xml');
102105
$loader->load('collectors.xml');
103106
$loader->load('guard.xml');

src/Symfony/Bundle/SecurityBundle/Resources/config/templating_php.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@
1010
<service id="templating.helper.logout_url" class="Symfony\Bundle\SecurityBundle\Templating\Helper\LogoutUrlHelper">
1111
<tag name="templating.helper" alias="logout_url" />
1212
<argument type="service" id="security.logout_url_generator" />
13+
14+
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
1315
</service>
1416

1517
<service id="templating.helper.security" class="Symfony\Bundle\SecurityBundle\Templating\Helper\SecurityHelper">
1618
<tag name="templating.helper" alias="security" />
1719
<argument type="service" id="security.authorization_checker" on-invalid="ignore" />
20+
21+
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
1822
</service>
1923
</services>
2024
</container>

src/Symfony/Bundle/SecurityBundle/Templating/Helper/LogoutUrlHelper.php

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

1212
namespace Symfony\Bundle\SecurityBundle\Templating\Helper;
1313

14+
@trigger_error('The '.LogoutUrlHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
15+
1416
use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator;
1517
use Symfony\Component\Templating\Helper\Helper;
1618

1719
/**
1820
* LogoutUrlHelper provides generator functions for the logout URL.
1921
*
2022
* @author Jeremy Mikola <jmikola@gmail.com>
23+
*
24+
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
2125
*/
2226
class LogoutUrlHelper extends Helper
2327
{

src/Symfony/Bundle/SecurityBundle/Templating/Helper/SecurityHelper.php

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

1212
namespace Symfony\Bundle\SecurityBundle\Templating\Helper;
1313

14+
@trigger_error('The '.SecurityHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
15+
1416
use Symfony\Component\Security\Acl\Voter\FieldVote;
1517
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
1618
use Symfony\Component\Templating\Helper\Helper;
@@ -19,6 +21,8 @@
1921
* SecurityHelper provides read-only access to the security checker.
2022
*
2123
* @author Fabien Potencier <fabien@symfony.com>
24+
*
25+
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
2226
*/
2327
class SecurityHelper extends Helper
2428
{

src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php

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

1212
namespace Symfony\Bundle\TwigBundle\Loader;
1313

14+
@trigger_error('The '.FilesystemLoader::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig notation for templates instead.', E_USER_DEPRECATED);
15+
1416
use Symfony\Component\Config\FileLocatorInterface;
1517
use Symfony\Component\Templating\TemplateNameParserInterface;
1618
use Symfony\Component\Templating\TemplateReferenceInterface;
@@ -22,6 +24,8 @@
2224
* to work with the Symfony paths and template references.
2325
*
2426
* @author Fabien Potencier <fabien@symfony.com>
27+
*
28+
* @deprecated since version 4.3, to be removed in 5.0; use Twig notation for templates instead.
2529
*/
2630
class FilesystemLoader extends BaseFilesystemLoader
2731
{

src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ public function stopwatchExtensionAvailabilityProvider()
280280
];
281281
}
282282

283+
/**
284+
* @group legacy
285+
*/
283286
public function testRuntimeLoader()
284287
{
285288
$container = $this->createContainer();

src/Symfony/Component/Form/Extension/Templating/TemplatingExtension.php

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

1212
namespace Symfony\Component\Form\Extension\Templating;
1313

14+
@trigger_error('The '.TemplatingExtension::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
15+
1416
use Symfony\Bundle\FrameworkBundle\Templating\Helper\FormHelper;
1517
use Symfony\Component\Form\AbstractExtension;
1618
use Symfony\Component\Form\FormRenderer;
@@ -21,6 +23,8 @@
2123
* Integrates the Templating component with the Form library.
2224
*
2325
* @author Bernhard Schussek <bschussek@gmail.com>
26+
*
27+
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
2428
*/
2529
class TemplatingExtension extends AbstractExtension
2630
{

src/Symfony/Component/Form/Extension/Templating/TemplatingRendererEngine.php

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

1212
namespace Symfony\Component\Form\Extension\Templating;
1313

14+
@trigger_error('The '.TemplatingRendererEngine::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
15+
1416
use Symfony\Component\Form\AbstractRendererEngine;
1517
use Symfony\Component\Form\FormView;
1618
use Symfony\Component\Templating\EngineInterface;
1719

1820
/**
1921
* @author Bernhard Schussek <bschussek@gmail.com>
22+
*
23+
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
2024
*/
2125
class TemplatingRendererEngine extends AbstractRendererEngine
2226
{

src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ public function setTemplating($templating)
5959
throw new \InvalidArgumentException('The hinclude rendering strategy needs an instance of Twig\Environment or Symfony\Component\Templating\EngineInterface');
6060
}
6161

62+
if ($templating instanceof EngineInterface) {
63+
@trigger_error(sprintf('Using a "%s" instance for "%s" is deprecated since version 4.3; use a \Twig\Environment instance instead.', EngineInterface::class, __CLASS__), E_USER_DEPRECATED);
64+
}
65+
6266
$this->templating = $templating;
6367
}
6468

src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Symfony\Component\HttpKernel\Controller\ControllerReference;
1717
use Symfony\Component\HttpKernel\Fragment\HIncludeFragmentRenderer;
1818
use Symfony\Component\HttpKernel\UriSigner;
19+
use Twig\Environment;
20+
use Twig\Loader\ArrayLoader;
1921

2022
class HIncludeFragmentRendererTest extends TestCase
2123
{
@@ -74,29 +76,26 @@ public function testRenderWithAttributesOptions()
7476
$this->assertEquals('<hx:include src="/foo" p1="v1" p2="v2" id="bar">default</hx:include>', $strategy->render('/foo', Request::create('/'), ['default' => 'default', 'id' => 'bar', 'attributes' => ['p1' => 'v1', 'p2' => 'v2']])->getContent());
7577
}
7678

77-
public function testRenderWithDefaultText()
79+
public function testRenderWithTwigAndDefaultText()
7880
{
79-
$engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock();
80-
$engine->expects($this->once())
81-
->method('exists')
82-
->with('default')
83-
->willThrowException(new \InvalidArgumentException());
84-
85-
// only default
86-
$strategy = new HIncludeFragmentRenderer($engine);
87-
$this->assertEquals('<hx:include src="/foo">default</hx:include>', $strategy->render('/foo', Request::create('/'), ['default' => 'default'])->getContent());
81+
$twig = new Environment($loader = new ArrayLoader());
82+
$strategy = new HIncludeFragmentRenderer($twig);
83+
$this->assertEquals('<hx:include src="/foo">loading...</hx:include>', $strategy->render('/foo', Request::create('/'), ['default' => 'loading...'])->getContent());
8884
}
8985

90-
public function testRenderWithEngineAndDefaultText()
86+
/**
87+
* @group legacy
88+
*/
89+
public function testRenderWithDefaultTextLegacy()
9190
{
9291
$engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock();
9392
$engine->expects($this->once())
9493
- C8D1 >method('exists')
95-
->with('loading...')
96-
->willThrowException(new \RuntimeException());
94+
->with('default')
95+
->willThrowException(new \InvalidArgumentException());
9796

9897
// only default
9998
$strategy = new HIncludeFragmentRenderer($engine);
100-
$this->assertEquals('<hx:include src="/foo">loading...</hx:include>', $strategy->render('/foo', Request::create('/'), ['default' => 'loading...'])->getContent());
99+
$this->assertEquals('<hx:include src="/foo">default</hx:include>', $strategy->render('/foo', Request::create('/'), ['default' => 'default'])->getContent());
101100
}
102101
}

src/Symfony/Component/HttpKernel/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"symfony/templating": "~3.4|~4.0",
4040
"symfony/translation": "~4.2",
4141
"symfony/var-dumper": "^4.1.1",
42-
"psr/cache": "~1.0"
42+
"psr/cache": "~1.0",
43+
"twig/twig": "^1.34|^2.4"
4344
},
4445
"provide": {
4546
"psr/log-implementation": "1.0"

0 commit comments

Comments
 (0)
0