From 2afd6142aa286156c5913bd4699e3f8cc36022d7 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 14 Jan 2015 12:12:46 +0100 Subject: [PATCH] removed deprecated Twig features --- src/Symfony/Bridge/Twig/AppVariable.php | 30 ------------ .../DependencyInjection/Configuration.php | 47 ------------------- .../Resources/config/schema/twig-1.0.xsd | 8 ---- .../TwigBundle/Resources/config/twig.xml | 1 - .../DependencyInjection/TwigExtensionTest.php | 38 --------------- .../TwigDefaultEscapingStrategy.php | 41 ---------------- src/Symfony/Bundle/TwigBundle/TwigEngine.php | 22 --------- 7 files changed, 187 deletions(-) delete mode 100644 src/Symfony/Bundle/TwigBundle/TwigDefaultEscapingStrategy.php diff --git a/src/Symfony/Bridge/Twig/AppVariable.php b/src/Symfony/Bridge/Twig/AppVariable.php index 5ffafc6a58..4117c58298 100644 --- a/src/Symfony/Bridge/Twig/AppVariable.php +++ b/src/Symfony/Bridge/Twig/AppVariable.php @@ -16,7 +16,6 @@ use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Symfony\Component\Security\Core\SecurityContextInterface; /** * Exposes some Symfony parameters and services as an "app" global variable. @@ -25,20 +24,11 @@ use Symfony\Component\Security\Core\SecurityContextInterface; */ class AppVariable { - private $security; private $tokenStorage; private $requestStack; private $environment; private $debug; - /** - * @deprecated since version 2.7, to be removed in 3.0. - */ - public function setSecurity(SecurityContextInterface $security) - { - $this->security = $security; - } - public function setTokenStorage(TokenStorageInterface $tokenStorage) { $this->tokenStorage = $tokenStorage; @@ -59,24 +49,6 @@ class AppVariable $this->debug = (bool) $debug; } - /** - * Returns the security context service. - * - * @deprecated since version 2.6, to be removed in 3.0. - * - * @return SecurityContext|null The security context - */ - public function getSecurity() - { - trigger_error('The "app.security" variable is deprecated since version 2.6 and will be removed in 3.0.', E_USER_DEPRECATED); - - if (null === $this->security) { - throw new \RuntimeException('The "app.security" variable is not available.'); - } - - return $this->security; - } - /** * Returns the current user. * @@ -88,8 +60,6 @@ class AppVariable { if (null !== $this->tokenStorage) { $tokenStorage = $this->tokenStorage; - } elseif (null !== $this->security) { - $tokenStorage = $this->security; } else { throw new \RuntimeException('The "app.user" variable is not available.'); } diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php index 7aaa48d476..e96286905b 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php @@ -38,7 +38,6 @@ class Configuration implements ConfigurationInterface ->end() ; - $this->addFormSection($rootNode); $this->addFormThemesSection($rootNode); $this->addGlobalsSection($rootNode); $this->addTwigOptions($rootNode); @@ -46,52 +45,6 @@ class Configuration implements ConfigurationInterface return $treeBuilder; } - private function addFormSection(ArrayNodeDefinition $rootNode) - { - $rootNode - // Check deprecation before the config is processed to ensure - // the setting has been explicitly defined in a configuration file. - ->beforeNormalization() - ->ifTrue(function ($v) { return isset($v['form']['resources']); }) - ->then(function ($v) { - trigger_error('The twig.form.resources configuration key is deprecated since version 2.6 and will be removed in 3.0. Use the twig.form_themes configuration key instead.', E_USER_DEPRECATED); - - return $v; - }) - ->end() - ->validate() - ->ifTrue(function ($v) { - return count($v['form']['resources']) > 0; - }) - ->then(function ($v) { - $v['form_themes'] = array_values(array_unique(array_merge($v['form']['resources'], $v['form_themes']))); - - return $v; - }) - ->end() - ->children() - ->arrayNode('form') - ->info('Deprecated since version 2.6, to be removed in 3.0. Use twig.form_themes instead') - ->addDefaultsIfNotSet() - ->fixXmlConfig('resource') - ->children() - ->arrayNode('resources') - ->addDefaultChildrenIfNoneSet() - ->prototype('scalar')->defaultValue('form_div_layout.html.twig')->end() - ->example(array('MyBundle::form.html.twig')) - ->validate() - ->ifTrue(function ($v) { return !in_array('form_div_layout.html.twig', $v); }) - ->then(function ($v) { - return array_merge(array('form_div_layout.html.twig'), $v); - }) - ->end() - ->end() - ->end() - ->end() - ->end() - ; - } - private function addFormThemesSection(ArrayNodeDefinition $rootNode) { $rootNode diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/schema/twig-1.0.xsd b/src/Symfony/Bundle/TwigBundle/Resources/config/schema/twig-1.0.xsd index 474b6c9721..3314091a08 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/schema/twig-1.0.xsd +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/schema/twig-1.0.xsd @@ -9,8 +9,6 @@ - - @@ -28,12 +26,6 @@ - - - - - - diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml index b8c75d2334..4bfe33687b 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml @@ -40,7 +40,6 @@ %kernel.environment% %kernel.debug% - diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php index c8dcf4e5d7..14c6b0cced 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -23,44 +23,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; class TwigExtensionTest extends TestCase { - /** - * @dataProvider getFormats - */ - public function testLegacyFormResourcesConfigurationKey($format) - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $container = $this->createContainer(); - $container->registerExtension(new TwigExtension()); - $this->loadFromFile($container, 'legacy-form-resources-only', $format); - $this->compileContainer($container); - - // Form resources - $this->assertCount(3, $container->getParameter('twig.form.resources')); - $this->assertContains('form_div_layout.html.twig', $container->getParameter('twig.form.resources')); - $this->assertContains('form_table_layout.html.twig', $container->getParameter('twig.form.resources')); - $this->assertContains('MyBundle:Form:my_theme.html.twig', $container->getParameter('twig.form.resources')); - } - - /** - * @dataProvider getFormats - */ - public function testLegacyMergeFormResourcesConfigurationKeyWithFormThemesConfigurationKey($format) - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $container = $this->createContainer(); - $container->registerExtension(new TwigExtension()); - $this->loadFromFile($container, 'legacy-merge-form-resources-with-form-themes', $format); - $this->compileContainer($container); - - $this->assertCount(4, $container->getParameter('twig.form.resources')); - $this->assertContains('form_div_layout.html.twig', $container->getParameter('twig.form.resources')); - $this->assertContains('form_table_layout.html.twig', $container->getParameter('twig.form.resources')); - $this->assertContains('MyBundle:Form:my_theme.html.twig', $container->getParameter('twig.form.resources')); - $this->assertContains('FooBundle:Form:bar.html.twig', $container->getParameter('twig.form.resources')); - } - public function testLoadEmptyConfiguration() { $container = $this->createContainer(); diff --git a/src/Symfony/Bundle/TwigBundle/TwigDefaultEscapingStrategy.php b/src/Symfony/Bundle/TwigBundle/TwigDefaultEscapingStrategy.php deleted file mode 100644 index 9c5a06069e..0000000000 --- a/src/Symfony/Bundle/TwigBundle/TwigDefaultEscapingStrategy.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle; - -trigger_error('The '.__NAMESPACE__.'\TwigDefaultEscapingStrategy class is deprecated in version 2.7 and will be removed in version 3.0. Use the "filename" auto-escaping strategy instead.', E_USER_DEPRECATED); - -/** - * @author Fabien Potencier - * - * @deprecated since version 2.7, will be removed in 3.0. Use the "filename" auto-escaping strategy instead. - */ -class TwigDefaultEscapingStrategy -{ - public static function guess($filename) - { - // remove .twig - $filename = substr($filename, 0, -5); - - // get the format - $format = substr($filename, strrpos($filename, '.') + 1); - - if ('js' === $format) { - return 'js'; - } - - if ('txt' === $format) { - return false; - } - - return 'html'; - } -} diff --git a/src/Symfony/Bundle/TwigBundle/TwigEngine.php b/src/Symfony/Bundle/TwigBundle/TwigEngine.php index 35640505c0..e1d7418796 100644 --- a/src/Symfony/Bundle/TwigBundle/TwigEngine.php +++ b/src/Symfony/Bundle/TwigBundle/TwigEngine.php @@ -41,28 +41,6 @@ class TwigEngine extends BaseEngine implements EngineInterface $this->locator = $locator; } - /** - * @deprecated since version 2.7, to be removed in 3.0. - * Inject the escaping strategy on \Twig_Environment instead. - */ - public function setDefaultEscapingStrategy($strategy) - { - trigger_error('The '.__METHOD__.' method is deprecated since version 2.7 and will be removed in 3.0. Inject the escaping strategy in the Twig_Environment object instead.', E_USER_DEPRECATED); - - $this->environment->getExtension('escaper')->setDefaultStrategy($strategy); - } - - /** - * @deprecated since version 2.7, to be removed in 3.0. - * Use the 'filename' strategy instead. - */ - public function guessDefaultEscapingStrategy($filename) - { - trigger_error('The '.__METHOD__.' method is deprecated since version 2.7 and will be removed in 3.0. Use the Twig_FileExtensionEscapingStrategy::guess method instead.', E_USER_DEPRECATED); - - return \Twig_FileExtensionEscapingStrategy::guess($filename); - } - /** * {@inheritdoc} */