mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-14 09:44:55 +02:00
Update Twig from 1.35.0 to 1.42.4 (PHP 5.5 is now required!)
This fixes some errors on PHP 7.4 and contains even more fixes Also bumped PHP version to 5.5 as Twig requires it.
This commit is contained in:
@@ -9,23 +9,25 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Twig;
|
||||
|
||||
/**
|
||||
* Exposes a template to userland.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
final class Twig_TemplateWrapper
|
||||
final class TemplateWrapper
|
||||
{
|
||||
private $env;
|
||||
private $template;
|
||||
|
||||
/**
|
||||
* This method is for internal use only and should never be called
|
||||
* directly (use Twig_Environment::load() instead).
|
||||
* directly (use Twig\Environment::load() instead).
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function __construct(Twig_Environment $env, Twig_Template $template)
|
||||
public function __construct(Environment $env, Template $template)
|
||||
{
|
||||
$this->env = $env;
|
||||
$this->template = $template;
|
||||
@@ -38,9 +40,11 @@ final class Twig_TemplateWrapper
|
||||
*
|
||||
* @return string The rendered template
|
||||
*/
|
||||
public function render($context = array())
|
||||
public function render($context = [])
|
||||
{
|
||||
return $this->template->render($context);
|
||||
// using func_get_args() allows to not expose the blocks argument
|
||||
// as it should only be used by internal code
|
||||
return $this->template->render($context, \func_num_args() > 1 ? func_get_arg(1) : []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,9 +52,11 @@ final class Twig_TemplateWrapper
|
||||
*
|
||||
* @param array $context An array of parameters to pass to the template
|
||||
*/
|
||||
public function display($context = array())
|
||||
public function display($context = [])
|
||||
{
|
||||
$this->template->display($context);
|
||||
// using func_get_args() allows to not expose the blocks argument
|
||||
// as it should only be used by internal code
|
||||
$this->template->display($context, \func_num_args() > 1 ? func_get_arg(1) : []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +67,7 @@ final class Twig_TemplateWrapper
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasBlock($name, $context = array())
|
||||
public function hasBlock($name, $context = [])
|
||||
{
|
||||
return $this->template->hasBlock($name, $context);
|
||||
}
|
||||
@@ -73,7 +79,7 @@ final class Twig_TemplateWrapper
|
||||
*
|
||||
* @return string[] An array of defined template block names
|
||||
*/
|
||||
public function getBlockNames($context = array())
|
||||
public function getBlockNames($context = [])
|
||||
{
|
||||
return $this->template->getBlockNames($context);
|
||||
}
|
||||
@@ -86,20 +92,24 @@ final class Twig_TemplateWrapper
|
||||
*
|
||||
* @return string The rendered block
|
||||
*/
|
||||
public function renderBlock($name, $context = array())
|
||||
public function renderBlock($name, $context = [])
|
||||
{
|
||||
$context = $this->env->mergeGlobals($context);
|
||||
$level = ob_get_level();
|
||||
ob_start();
|
||||
if ($this->env->isDebug()) {
|
||||
ob_start();
|
||||
} else {
|
||||
ob_start(function () { return ''; });
|
||||
}
|
||||
try {
|
||||
$this->template->displayBlock($name, $context);
|
||||
} catch (Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
while (ob_get_level() > $level) {
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
throw $e;
|
||||
} catch (Throwable $e) {
|
||||
} catch (\Throwable $e) {
|
||||
while (ob_get_level() > $level) {
|
||||
ob_end_clean();
|
||||
}
|
||||
@@ -116,18 +126,36 @@ final class Twig_TemplateWrapper
|
||||
* @param string $name The block name to render
|
||||
* @param array $context An array of parameters to pass to the template
|
||||
*/
|
||||
public function displayBlock($name, $context = array())
|
||||
public function displayBlock($name, $context = [])
|
||||
{
|
||||
$this->template->displayBlock($name, $this->env->mergeGlobals($context));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Twig_Source
|
||||
* @return Source
|
||||
*/
|
||||
public function getSourceContext()
|
||||
{
|
||||
return $this->template->getSourceContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTemplateName()
|
||||
{
|
||||
return $this->template->getTemplateName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @return Template
|
||||
*/
|
||||
public function unwrap()
|
||||
{
|
||||
return $this->template;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('Twig_TemplateWrapper', 'Twig\TemplateWrapper', false);
|
||||
class_alias('Twig\TemplateWrapper', 'Twig_TemplateWrapper');
|
||||
|
Reference in New Issue
Block a user