mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-11 09:56:32 +00:00
deprecated the possibility to change the base template for generated templates
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user