Skip to content

Commit

Permalink
Merge pull request #861 from acrobat/twig2-bc-fix
Browse files Browse the repository at this point in the history
Twig 2 bc fixes
  • Loading branch information
greg0ire authored Sep 6, 2017
2 parents 1c8844e + 6dc46d9 commit bf06f3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion Controller/PageAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,15 @@ public function treeAction(Request $request = null)
$datagrid = $this->admin->getDatagrid();
$formView = $datagrid->getForm()->createView();

$this->get('twig')->getExtension('form')->renderer->setTheme($formView, $this->admin->getFilterTheme());
// NEXT_MAJOR: remove bc check
// BC for Symfony < 3.2 where this runtime does not exist
$twig = $this->get('twig');
$theme = $this->admin->getFilterTheme();
if (!method_exists('Symfony\Bridge\Twig\AppVariable', 'getToken')) {
$twig->getExtension('Symfony\Bridge\Twig\Extension\FormExtension')->renderer->setTheme($formView, $theme);
} else {
$twig->getRuntime('Symfony\Bridge\Twig\Form\TwigRenderer')->setTheme($formView, $theme);
}

return $this->render($this->admin->getTemplate('tree'), array(
'action' => 'tree',
Expand Down
3 changes: 2 additions & 1 deletion Resources/views/PageAdmin/tree.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ file that was distributed with this source code.
<a class="label label-default pull-right" href="{{ admin.generateObjectUrl('compose', page) }}">{{ 'pages.compose_label'|trans({}, 'SonataPageBundle') }} <i class="fa fa-magic"></i></a>
{% if page.edited %}<span class="label label-warning pull-right">{{ 'pages.edited_label'|trans({}, 'SonataPageBundle') }}</span>{% endif %}
</div>
{% import _self as macro %}
{% if page.children|length %}
{{ _self.pages(page.children, admin, false) }}
{{ macro.pages(page.children, admin, false) }}
{% endif %}
</li>
{% endfor %}
Expand Down

0 comments on commit bf06f3d

Please sign in to comment.