Describe the bug
When any template extends @EasyAdmin/page/content.html.twig, the page throws a runtime error because templatePath() is called on AdminContextProvider instead of AdminContext.
The template uses this pattern to rebind the ea global before extending:
{% set ea = ea() %}
{% extends null != ea ? ea.templatePath('layout') : '@EasyAdmin/layout.html.twig' %}
This does not work as intended. Twig compiles the {% extends %} expression into doGetParent() and the {% set %} into doDisplay(). Since doGetParent() runs before doDisplay(), the local ea reassignment has not happened yet when the extends expression is evaluated.
Neither the property "templatePath" nor one of the methods "templatePath()", "gettemplatePath()",
"istemplatePath()", "hastemplatePath()" or "__call()" exist and have public access in class
"EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider"
in @EasyAdmin/page/content.html.twig at line 3.
To Reproduce
Create a template that extends @EasyAdmin/page/content.html.twig
Navigate to the admin page that renders that template
EasyAdminBundle version: 5.0.6
Twig: 3.24.0
Symfony: 7.4
PHP: 8.4.20
Additional context
The fix is to call ea() directly in the {% extends %} expression, bypassing the {% set %} / doGetParent() ordering issue:
{% extends ea() is not null ? ea().templatePath('layout') : '@EasyAdmin/layout.html.twig' %}
{% trans_default_domain ea() is not null ? ea().i18n.translationDomain : (translation_domain is defined ? translation_domain ?? 'messages') %}
{% block body_class 'page-content' %}
{% block content_title %}{% endblock %}
{% block main %}{% endblock %}
Workaround
Override the template in your project at templates/bundles/EasyAdminBundle/page/content.html.twig with fixed content from above
Describe the bug
When any template extends @EasyAdmin/page/content.html.twig, the page throws a runtime error because templatePath() is called on AdminContextProvider instead of AdminContext.
The template uses this pattern to rebind the ea global before extending:
This does not work as intended. Twig compiles the {% extends %} expression into doGetParent() and the {% set %} into doDisplay(). Since doGetParent() runs before doDisplay(), the local ea reassignment has not happened yet when the extends expression is evaluated.
To Reproduce
Create a template that extends @EasyAdmin/page/content.html.twig
Navigate to the admin page that renders that template
EasyAdminBundle version: 5.0.6
Twig: 3.24.0
Symfony: 7.4
PHP: 8.4.20
Additional context
The fix is to call ea() directly in the {% extends %} expression, bypassing the {% set %} / doGetParent() ordering issue:
Workaround
Override the template in your project at templates/bundles/EasyAdminBundle/page/content.html.twig with fixed content from above