Skip to content

Commit 57588e3

Browse files
npotiermhor
andauthored
fix Twig deprecated method call (#1076) (#1081)
Co-authored-by: Maxime Horcholle <maxime.horcholle@socloz.com>
1 parent 583cd0b commit 57588e3

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

Grid/Export/Export.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
namespace APY\DataGridBundle\Grid\Export;
1414

1515
use APY\DataGridBundle\Grid\Column\ArrayColumn;
16+
use APY\DataGridBundle\Grid\Grid;
1617
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
1718
use Symfony\Component\DependencyInjection\ContainerInterface;
1819
use Symfony\Component\HttpFoundation\Response;
20+
use Twig\TemplateWrapper;
1921

2022
abstract class Export implements ExportInterface, ContainerAwareInterface
2123
{
@@ -441,12 +443,12 @@ public function setTemplate($template)
441443
if (is_string($template)) {
442444
if (substr($template, 0, 8) === '__SELF__') {
443445
$this->templates = $this->getTemplatesFromString(substr($template, 8));
444-
$this->templates[] = $this->twig->loadTemplate(static::DEFAULT_TEMPLATE);
446+
$this->templates[] = $this->twig->load(static::DEFAULT_TEMPLATE);
445447
} else {
446448
$this->templates = $this->getTemplatesFromString($template);
447449
}
448450
} elseif ($this->templates === null) {
449-
$this->templates[] = $this->twig->loadTemplate(static::DEFAULT_TEMPLATE);
451+
$this->templates[] = $this->twig->load(static::DEFAULT_TEMPLATE);
450452
} else {
451453
throw new \Exception('Unable to load template');
452454
}
@@ -457,13 +459,10 @@ public function setTemplate($template)
457459
protected function getTemplatesFromString($theme)
458460
{
459461
$templates = [];
460-
461-
$template = $this->twig->loadTemplate($theme);
462-
while ($template instanceof TemplateWrapper) {
462+
$template = $this->twig->load($theme);
463+
if ($template instanceof TemplateWrapper) {
463464
$templates[] = $template;
464-
$template = $template->getParent([]);
465465
}
466-
467466
return $templates;
468467
}
469468

0 commit comments

Comments
 (0)