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

introduce catamorphism for ui components #8812

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

Conversation

nhaagen
Copy link
Contributor

@nhaagen nhaagen commented Jan 9, 2025

UI Components inductively built upon each other, i.e. components will contain other components.
It is, for some components, possible to access their substructure, but always in a specific manner; there is no generic way to get from the containing component to its children.

Now, @jeph864 is working on Activities and the idea arose to use forms/inputs to publish APIs (see #8746). What's missing right now is a simple way to fold down the inputs into e.g. some json-object, and while at it, this is true for all components.

Therefore, I implemented a mechanism on the componentHelper to walk down the object tree and apply operations to the components, storing the result in a property. This result does not need to stay a component, and you can see its effect quite clearly in the examples included here. Also, modification of the components' instances are perfectly feasible.

Components need to implement getSubStructure(): array to participate in the catamorphism; if they don't or return an empty array, recursion just stops and the component is considered a leaf-node.

This implementation comes with Container and Field\Group for now, but is explicitely meant for all UI Components.
I fiddled around wit the Panel, e.g., and it behaves just alike.

@nhaagen nhaagen force-pushed the 11/UIComponent/Catamorphism branch from addded5 to a47c5b4 Compare January 9, 2025 15:03
@mjansenDatabay mjansenDatabay added improvement php Pull requests that update Php code labels Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement php Pull requests that update Php code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants