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

Enhancement Allow overriding or extending the normalize() method for nested fields #714

Open
Stolidbug opened this issue Jan 13, 2025 · 0 comments

Comments

@Stolidbug
Copy link


Q A
Bug? no
New Feature? no
SuluArticleBundle Version 2.6
Sulu Version 2.6.6

Actual Behavior

Currently, the normalize() method in ArticleController is declared as private. This prevents developers from overriding or extending it in their own controllers when they need to handle nested fields (for example, accessing excerpt.categories[0].name). As a result, we have to copy the entire cgetAction and replicate the exact logic, just to inject a small piece of custom field processing.

Expected Behavior

It would be ideal if the normalize() method (or at least the portion of the code that processes fields) could be made protected, or if there was another extension point (e.g., an event/hook) allowing developers to handle nested fields without needing to duplicate the logic from the parent class.

Steps to Reproduce

  1. Extend ArticleController in a custom bundle.
  2. Attempt to override normalize() to handle nested data.
  3. Notice that normalize() is private, so it cannot be called or overwritten from the child class.
  4. The only workaround is to duplicate a large portion of the parent method (e.g., cgetAction) and replace the normalize call.

Possible Solutions

  • Make normalize() protected: This would allow child classes to override and add custom logic.
  • Add a dedicated extension point or event: So that nested fields can be handled without copying the whole controller action.
  • Support multi-level field descriptors: For instance, a field descriptor could point to excerpt.categories.0.name, and the code could parse that path internally.

Thank you for considering this enhancement. If you have any questions or suggestions, please let me know!

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

1 participant