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

[FEATURE] UI: improve context rendering #7460

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

thibsy
Copy link
Contributor

@thibsy thibsy commented May 1, 2024

Hi folks,

I have removed some unnecessary complexity from the UI framework:

  • Renderer::withAdditionalContext(): this method has been invoked in order to provide a context to the current rendering chain. However, due to the recursive nature of our rendering process, we can always know the current context because all rendering calls will eventually invoke our DefaultRenderer again. I have discussed with @klees to replace usages of this method by creating a new instance of the concrete context renderer already. However, I have decided not to do so until we have a proper mechanism to gather assets and inject them into our page component.
  • RendererFactory::getJSBinding(): since instances are passed by reference, we can simply inject the JavaScriptBinding directly into our DefaultRenderer. No need to retrieve the RendererFactory and/or ComponentRenderer again.

Kind regards,
@thibsy

@thibsy thibsy force-pushed the feature/10/ui-improve-context-rendering branch from a135508 to d9ffec7 Compare May 1, 2024 15:34
@thibsy thibsy added kitchen sink improvement php Pull requests that update Php code labels May 2, 2024
Copy link
Member

@klees klees left a comment

Choose a reason for hiding this comment

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

Hi @thibsy,

thanks a lot for iterating here. These pieces look a lot more manageable than the huge change we discussed before and also have benefit on their own. This feels good.

Please consider the following suggestions. You do not need to follow those, but but please indicate shortly why you prefer to do otherwise:

  • popContext: A downside of replacing that stateless withAdditionalContext by internal context management is that some out of band control flow (exceptions, mostly, hopefully nobody uses labels ans goto anymore...) could leave the DefaultRenderer in some invalid state. If there is some exception in between addContext and popContext, the internal $contexts property will get out of sync with reality. This most likely won't be a problem, since system would be crashing somehow anyway. On the other hand this is exactly the kind of thing that will drive someone nuts when debugging. Please use finally to make sure that popContext will be called anyway, even if exceptions are flying.

The rest LGTU.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement kitchen sink php Pull requests that update Php code
Projects
None yet
3 participants