deprecated the possibility to change the base template for generated templates

This commit is contained in:
Fabien Potencier
2019-02-16 23:09:13 +01:00
parent e37d86fca9
commit 3f71217f63
4 changed files with 23 additions and 1 deletions
+3
View File
@@ -1,5 +1,8 @@
* 2.7.0 (2019-XX-XX)
* deprecated the "base_template_class" option on Twig\Environment
* deprecated the ``Twig\Environment::getBaseTemplateClass()`` and
``Twig\Environment::setBaseTemplateClass()`` methods
* changed internal code to use the namespaced classes as much as possible
* deprecated Twig_Parser::isReservedMacroName()
+10
View File
@@ -45,3 +45,13 @@ Parser
* As of Twig 2.7, the ``\Twig\Parser::isReservedMacroName()`` / ``Twig\Parser``
function is deprecated and will be removed in Twig 3.0. It always returns
``false`` anyway as Twig 2 does not have any reserved macro names.
Environment
-----------
* As of Twig 2.7, the ``base_template_class`` option on ``Twig\Environment`` is
deprecated and will be removed in Twig 3.0.
* As of Twig 2.7, the ``Twig\Environment::getBaseTemplateClass()`` and
``Twig\Environment::setBaseTemplateClass()`` methods are deprecated and will
be removed in Twig 3.0.
+9
View File
@@ -96,6 +96,9 @@ class Twig_Environment
$this->debug = (bool) $options['debug'];
$this->setCharset($options['charset']);
$this->baseTemplateClass = $options['base_template_class'];
if ('\Twig\Template' !== $options['base_template_class']) {
@trigger_error('The "base_template_class" option on '.__CLASS__.' is deprecated since Twig 2.7.0.', E_USER_DEPRECATED);
}
$this->autoReload = null === $options['auto_reload'] ? $this->debug : (bool) $options['auto_reload'];
$this->strictVariables = (bool) $options['strict_variables'];
$this->setCache($options['cache']);
@@ -113,6 +116,10 @@ class Twig_Environment
*/
public function getBaseTemplateClass()
{
if (1 > \func_num_args() || \func_get_arg(0)) {
@trigger_error('The '.__METHOD__.' is deprecated since Twig 2.7.0.', E_USER_DEPRECATED);
}
return $this->baseTemplateClass;
}
@@ -123,6 +130,8 @@ class Twig_Environment
*/
public function setBaseTemplateClass($class)
{
@trigger_error('The '.__METHOD__.' is deprecated since Twig 2.7.0.', E_USER_DEPRECATED);
$this->baseTemplateClass = $class;
$this->updateOptionsHash();
}
+1 -1
View File
@@ -143,7 +143,7 @@ class Twig_Node_Module extends \Twig\Node\Node
// if the template name contains */, add a blank to avoid a PHP parse error
->write('/* '.str_replace('*/', '* /', $this->source->getName())." */\n")
->write('class '.$compiler->getEnvironment()->getTemplateClass($this->source->getName(), $this->getAttribute('index')))
->raw(sprintf(" extends %s\n", $compiler->getEnvironment()->getBaseTemplateClass()))
->raw(sprintf(" extends %s\n", $compiler->getEnvironment()->getBaseTemplateClass(false)))
->write("{\n")
->indent()
->write("private \$source;\n\n")