Repository navigation
Merged
Conversation
… pool and language forms Meta info is part of the core, so it no longer hooks into the forms and save routines via extension points. The new `MetaForm` holds the meta fields of an item: the pages and api functions validate the submitted values before saving the item and pass the form to the `add()`/`edit()` methods of `CategoryHandler`, `ArticleHandler`, `MediaHandler` and `LanguageHandler`, which write the values within their own statements. Invalid meta values therefore no longer leave an item saved without them. Nothing is saved, the form is shown again with the submitted values and the errors at the fields; the category form stays open for this. The handler classes in `MetaInfo\Handler` are removed. The meta check of `MediaPool::mediaIsInUse()` moves to `MetaInfo\MediaUsage` and is called directly. The article meta sidebar saves via `ArticleHandler::edit()`, so `ART_META_UPDATED` is replaced by `ArticleUpdated`. `ArticleHandler::edit()` keeps the template if `template` is not passed. The form extension points (`CAT_FORM_*`, `MEDIA_FORM_*`, `LanguageForm*`, `STRUCTURE_CONTENT_SIDEBAR`, `MEDIA_IS_IN_USE`) stay available for addons.
The add()/edit() methods of the category, article, media and language handlers take the meta values as plain array keyed by the storage key of the field, instead of the MetaForm, so they can be called with explicit values, e.g. by addons or the project. Only the given values are saved. The new MetaValues converts them into the column values and rejects unknown keys and values not matching the property type, before anything is written. MetaForm::values() returns the submitted values for the backend pages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Meta info is part of the core now, so it no longer needs to hook into the forms and save routines of categories, articles, media and languages via extension points.
Changes
add()/edit()methods ofCategoryHandler,ArticleHandler,MediaHandlerandLanguageHandler(ArticleHandler::add()included, although the backend form for adding articles has no meta fields) take an optionalarray $meta, keyed by the storage key of the field (the column without themeta_prefix), each value of the property type. Only the given values are saved, so they can also be called with explicit values, e.g. by addons or the project:MetaInfo\MetaValuesconverts them into the column values and rejects unknown keys and values not matching the property type before anything is written. The handlers save the values within their own insert/update statements.MetaInfo\MetaFormholds the meta fields of an item in the backend forms (submit(),hasErrors(),render(),values()). It replaces the classes inMetaInfo\Handler\*. The pages and api functions validate the submitted values before saving the item and pass$metaForm->values()to the handler.CategoryAddedetc. threw after the item had been saved). Now nothing is saved, and the form is shown again with the submitted values and the errors at the fields. The category form stays open for this, and the meta row of categories and languages expands.boot/backend.phpno longer registers meta info listeners. The article meta sidebar is included directly bycontent.php.MediaPool::mediaIsInUse()moves toMetaInfo\MediaUsageand is called directly.ART_META_UPDATEDis removed: the sidebar saves viaArticleHandler::edit(), which dispatchesArticleUpdated(rector rule added).ArticleHandler::edit()keeps the template if thetemplatekey is missing (previously it fell back to the first allowed template).MediaHandler::edit()writes the translation only after the file checks.minfo_metadata_not_savedbecomesminfo_metadata_invalid. The rector class mappingsrex_metainfo_*_handlerare removed, as their target classes are gone.The form extension points (
CAT_FORM_*,MEDIA_FORM_*,LanguageForm*,STRUCTURE_CONTENT_SIDEBAR,MEDIA_IS_IN_USE) stay available for addons.Testing
MetaValuesTestand aMediaHandlerTestcase cover the array API, including partial updates.Tested in the browser with temporary meta schemas (a shared field with
maxLengthplus a required translated field per entity): adding and editing languages and categories, the article sidebar, and media upload and edit, each first with invalid and then with valid values.