Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to a member function getI18n() on null #6473

Closed
ben29 opened this issue Oct 13, 2024 · 6 comments
Closed

Call to a member function getI18n() on null #6473

ben29 opened this issue Oct 13, 2024 · 6 comments

Comments

@ben29
Copy link

ben29 commented Oct 13, 2024

Describe the bug
after update to version 4.13.0 getting error on login page.

To Reproduce

        $error = $helper->getLastAuthenticationError();
        $lastUsername = $helper->getLastUsername();

        return $this->render(view: '@EasyAdmin/page/login.html.twig', parameters: [
            'error' => $error,
            'last_username' => $lastUsername,
            'translation_domain' => 'admin',
        ]);

same like here:

https://symfony.com/bundles/EasyAdminBundle/4.x/dashboards.html#login-form-template

Screenshot 2024-10-13 at 21 03 36
@javiereguiluz
Copy link
Collaborator

@ben29 thanks for reporting. I don't use the login feature myself in any application so, can you please debug this to find the cause of the error? Thanks!

@fracsi
Copy link
Contributor

fracsi commented Oct 14, 2024

The exception error comes from the AdminContextProvider.
image

@fracsi
Copy link
Contributor

fracsi commented Oct 14, 2024

The login template checks if ea is defined

{% extends ea is defined ? ea.templatePath('layout') : '@EasyAdmin/page/login_minimal.html.twig' %}
{% trans_default_domain ea is defined ? ea.i18n.translationDomain : (translation_domain is defined ? translation_domain ?? 'messages') %}

Previously it was null if there was no context in the request, now it is always defined (AdminContextProvider) - see #6273

javiereguiluz added a commit that referenced this issue Oct 14, 2024
This PR was merged into the 4.x branch.

Discussion
----------

`ea` twig variable existence check fix

Fix for #6473

Added `hasContext` method to check for AdminContext existence instead of relying on `is defined`.
#6273 made `ea` twig global variable always defined.

Commits
-------

6c817f9 Add hasContext in AdminContextProvider
@javiereguiluz
Copy link
Collaborator

Closing as fixed in #6475. Thanks.

@Geolim4
Copy link
Contributor

Geolim4 commented Oct 30, 2024

@javiereguiluz the problem still occurs with @EasyAdmin/page/content.html.twig to make a page without crud controller as per symfony docs:

https://symfony.com/bundles/EasyAdminBundle/current/dashboards.html#content-page-template

@javiereguiluz
Copy link
Collaborator

Thanks for reporting this. It's being fixed in #6497.

javiereguiluz added a commit that referenced this issue Nov 4, 2024
…javiereguiluz)

This PR was merged into the 4.x branch.

Discussion
----------

Fix an issue when accessing a variable in a Twig template

Same as fixed in #6473.

Commits
-------

b803a97 Fix an issue when accessing a variable in a Twig template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants