Add entity paths to schema & APIv4 #18887
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This adds metadata to some entities (hopefully more will be added in the future) for the paths at which they can be created/updated/viewed/deleted. The metadata is accessed via the DAO, and exposed to APIv4.
Technical Details
Entity paths can be used to construct a url to create/view/edit/update a given entity.
The paths are local and contain tokens which would need to be replaced, e.g. [id] or [contact_id].
The token name corresponds to the field name who's value is required.
Comments
This kind of thing has been tried before. Six years ago, @totten created
CRM_Utils_System::createDefaultCrudLink()
which had a similar ambition to provide links for many entities. Sadly it never really got off the ground, and to-date still only supports 1 entity (Contacts). I considered extending that instead of striking out with a new initiative, but that function was heavily coupled to the DAO and could only generate links to existing entities. I needed something more flexible that could provide url templates for any entity supported by the API, without requiring a live DB connection to run.