The path into core¶
The proof of concept has an example of each kind of data below. They show that the approach works; they are not the code core would take, and core does not take everything as one piece. It moves as a small foundation, and then one kind of data at a time. Each piece is reviewed by the maintainers of the subsystem it touches and pays off on its own.
| Piece | What it needs first |
|---|---|
| The foundation: Portable Schema, structures, resources and operations | Nothing |
| Simple config | The foundation |
| Config entities | The foundation |
| Plugin settings | Portable Schema |
| Config that holds plugins | Config entities and plugin settings |
| Content entities | The foundation |
| Generated forms | The kind of data the form edits |
Simple config comes first because it is the simplest, and config entities before plugin settings because most settings people edit are config entities. Content entities go beside all of these, because what they still need is different.
The foundation¶
Portable Schema. The builder a module declares its keys with, and the validators that check values against them. Where a module has no Portable Schema definitions of its own, they are filled in by reading what it has: config schema, field definitions or a JSON Schema document. A module describes the data it owns once, and PHP and JavaScript check it by the same rules.
Structures, resources and operations. A structure describes a thing's data. A resource is a structure with a place to store it, and its operations are the actions on it, each with a permission and an input that is checked the same way wherever it comes from. From each operation come a Tool API tool, an HTTP endpoint with its OpenAPI description, and a Drush command.
One kind of data at a time¶
Simple config¶
A settings object such as site information.
| Core has | Config schema, and a form whose route asks a permission. Config::save() casts values to the schema and checks no constraint |
| Core gains | Operations on a config object beside its form(s), each with a permission. A write through one checks the whole object against its schema before anything is saved |
| Not solved | Another module's keys have no place to be stored. A form that already maps its elements to config with #config_target, and the resource beside it, do not yet describe the same thing |
Examples: Site information, with its keys declared as core would declare them, and the performance settings, with two of their keys read from config schema.
Config entities¶
A content type or a user role. Most of a site's structure is stored this way.
| Core has | Storage, an access handler, forms and routes. An entity form sets its values on the entity, and saving casts them to the schema and checks no constraint |
| Core gains | A resource beside the entity type's form and access handlers, with create, update and delete as operations. What would be saved is checked against its config schema first |
| Not solved | Config schema does not say which keys a person sets and which code sets, so a resource cannot be derived from it and is written by hand |
Example: Content types, with a form beside core's for adding and editing one.
Plugin settings¶
The settings of a block, a formatter or a condition. They are a structure, with no operations of their own: whatever uses the plugin stores them.
| Core has | Config schema for each plugin, its default settings, and a form with build, validate and submit methods |
| Core gains | A plugin names its structure, on its own class or a separate one. The settings form, its checks and the defaults come from it, and so does what any operation that uses the plugin accepts |
| Not solved | A field type's storage settings have no form drawn from a structure yet. Image effects, CKEditor 5 plugins and media sources are not tried |
Examples: A block and a formatter whose settings forms come from a structure, and the address field's settings from the contributed Address module.
Config that holds plugins¶
A placed block, a field, an image style or a text format: a config entity whose settings depend on which plugin was chosen, or on a list of them.
| Core has | What config entities have, and plugin collections |
| Core gains | A settings key that depends on the plugin chosen. It is read from the structure the plugin declares, or from the plugin's config schema where it declares none |
| Not solved | Image styles and text formats, whose plugins are lists a person orders, are the next ones to try. A block plugin that needs a context is not offered |
Examples: Placed blocks, with their list of visibility conditions, and fields with their storage.
Content entities¶
A node, a media item or a user. Core already has most of what an operation needs here, so nobody writes a class: each bundle's resource is derived from its field definitions.
| Core has | Field definitions, storage, access per field, and validation that content forms and JSON:API run. JSON:API already reads and writes them |
| Core gains | Named operations with one description of their input, the same for a form, a Tool API tool, HTTP and Drush |
| Not solved | Changing one value of a multi-value field without sending the others, translations, and what other modules add to the form, such as a path alias, a menu link or the moderation state. Keys another module adds have nowhere to be stored. How this relates to JSON:API is open |
Example: A basic page created, edited and deleted through operations derived from its field definitions. A field with several values is a list, and a write sends the whole list.
Nothing here waits for the config work, and the config work does not wait for it.
Generated forms, when wanted¶
A form drawn from the same description is the last part of each kind, not a last step for everything. An owner can switch its simple config form while nobody has touched content entities, or never switch. Nothing asks Form API to change before the first of them.
Not on the path yet¶
- Views. Its plugins define their options in a language of their own. Reading it is worth trying, but it is not a small adapter.
- Menu links. Their forms write to the menu tree, which is neither config nor a content entity.
At the same time¶
Groundwork in core (Groundwork). Core's data definitions learn to state a default, examples, labels for choices, and rules that depend on another key, such as a price that is required only when pricing is "paid". These changes can land now. A module that changes nothing is still read from its config schema and field definitions, so the more those can state, the more it offers without any work of its own. A declared key states all of these already, so the two do not wait for each other.
A place in simple config for another module's keys. A key an alter adds to a config entity is stored in the third-party settings core already gives it. Simple config has no such place, so a module that extends it keeps a config object of its own. A small change to core would give it one, and nothing waits for it.
How a piece moves¶
Each is prototyped in the proof of concept, extracted as a change to one core subsystem, tried on real core and contributed modules, filed as a core issue that stands on its own, and reviewed by that subsystem's maintainers. What review changes goes back into the proof of concept.
None of these pieces is drafted as a core issue yet. Three groundwork issues are open in core's queue, and the rest of the groundwork is drafted in the proof of concept's core gaps, which still uses an earlier order of five steps.
What stays out¶
Staged edits, a React client and a code generator stay in the proof of concept and are not proposed now (Stays in the proof of concept).
TBD
HTTP endpoints and their OpenAPI document are assumed throughout; where they live is open.
The proof of concept shows that a thing's rules can be stated once and that every way in can be held to them. It does not show that this order is the only one, or that its PHP API is the one core should adopt. Whether each piece fits a minor release is checked on Release fit.
TBD
Where the pieces land in core, and under which names, is an open question. The foundation also depends on which schema language core adopts, and on its license (open question).