Skip to content

[3.x] [RFC] Static, cached, identifiable contexts #3623

@lukasluecke

Description

@lukasluecke

Short description of what this feature will allow to do:
I'm working on a lot of advanced functionalities right now that require accessing different AdminContext instances, or at least parts of them (e.g. #3543 and #3551). The current way to pass and access this information is really not that great, I need to pass a lot of different meta identifiers, and then reconstruct the partial context later on (e.g. https://github.com/EasyCorp/EasyAdminBundle/pull/3543/files#diff-d495082da6d75b5637e8a71f9a16757fR9 or https://github.com/EasyCorp/EasyAdminBundle/pull/3551/files#diff-72cd37bdc6a6819e65f18366f1072f63R400).

My idea would be to statically generate parts of the context (right now I think the most useful, and at the same time most easily converted would be the CrudDto), give them an identifier similar to the crudId we use for controller mappings already, and cache them all. Then we could just pass this identifier, get the static instance from cache, "hydrate" it with our dynamic request data, and be done with it. (This would mean that e.g. in configureFields we would not allow any direct access to the entity instance, instead allowing callbacks for helper functions to define this dynamic behaviour - ->displayIf(function() { return $this->getContext()->getRequest()->has('showMyField'); });)

Example of how to use this feature
TBD

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions