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

Replace ea variable with a Twig function ea_context #6209

Open
wants to merge 4 commits into
base: 4.x
Choose a base branch
from

Conversation

GromNaN
Copy link

@GromNaN GromNaN commented Mar 18, 2024

Fix #5591 (see #5591 (comment))

The Twig environment is instantiated lazily when the first template is rendered, this is why it's possible to set the global variable ea conditionally depending on the current HTTP request. But this is fragile if there is anything that renders a template earlier.

In particular, this mechanism does not work with the worker modes of FrankenPHP and RoadRunner: the Twig environment is not reinitialized between HTTP requests.

  • Introduces a new function ea_context to lazy-load the AdminContext from the current HTTP request. The name can be discussed.
  • The ea global variable is deprecated and replaced in all the templates.

@@ -70,6 +75,7 @@ public function getGlobals(): array
$context = $this->adminContextProvider->getContext();

// when there's an admin context, make it available in all templates as a short named variable
// @deprecated
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The global variable is kept for backward compatibility. It can be removed for next major release.

@GromNaN GromNaN marked this pull request as ready for review March 18, 2024 13:40
@Seb33300
Copy link
Contributor

Seb33300 commented May 5, 2024

Instead of ea_context() maybe just ea()?

@GromNaN
Copy link
Author

GromNaN commented May 5, 2024

Replaced by #6273

@GromNaN GromNaN closed this May 5, 2024
@GromNaN GromNaN reopened this May 5, 2024
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

Successfully merging this pull request may close these issues.

EasyAdmin is not compatible with RoadRunner PHP app server
3 participants