Split monolithic designLoader plugin into design, translation and design change plugins (#29735) - #41123
Open
lbajsarowicz wants to merge 1 commit into
Open
Conversation
…ign change plugins (magento#29735) DesignLoader::load() bundled loading of the design part, the translation part and the store design change behind a single designLoader plugin, so an Action that renders no layout and no translated output could not opt out of the expensive parts without losing design initialization as well. The plugin is now three plugins with explicit sort orders that preserve the existing execution order, and DesignLoader::load() keeps its current behavior for direct callers. Fixes magento#29735
|
Hi @lbajsarowicz. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
Contributor
Author
|
@magento run all tests |
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.
Description (*)
Magento\Theme\Plugin\LoadDesignPlugin, declared as the singledesignLoaderplugin onMagento\Framework\App\ActionInterface(frontend and adminhtml), triggersMagento\Framework\View\DesignLoader::load(), which bundles three unrelated responsibilities into one call:Consequence: an Action that renders no layout and no translated output — a JSON/AJAX endpoint, a lightweight custom controller — still pays for loading the full translation dictionary and for design-change detection on every request. The only escape hatch today is
<plugin name="designLoader" disabled="true"/>, which also removes design initialization, so the Action loses the design it may still need (e.g. for image resizing via the theme view configuration).This PR splits the monolith into three independently disable-able plugins, without changing any default behavior:
sortOrderdesignLoaderArea::PART_DESIGNtranslationLoaderArea::PART_TRANSLATEdesignChangeLoaderArea::detectDesign()A developer can now keep design initialization and opt out of just the expensive parts:
Why this split, and why the sort orders are explicit — the current execution order is load-bearing and is preserved exactly:
PART_DESIGNmust run first:Area::_initDesign()sets the area and the default design theme.PART_TRANSLATEmust run second:Area::_initTranslate()→Translate::loadData()resolves theme translation files from the design theme set in step 1.detectDesign()must run last: it may change the design (store design change or user-agent design exception) after translations were already resolved against the default theme. Moving it earlier would silently change which translation files are loaded on stores that use design changes or design exceptions.Area::_loadPart()is idempotent (guarded by$this->_loadedParts), so splitting the calls across three plugins cannot cause double loading.DesignLoader::load()is unchanged and still performs all three steps in the same order and with a singleAreaList::getArea()call — existing callers (Magento\Backend\App\Action\Plugin\LoadDesignPlugin,Magento\Catalog\Ui\DataProvider\Product\Listing\Collector\Image) are unaffected. Three granular methods were added next to it:loadDesign(),loadTranslation(),applyDesignChange().The
LocalizedException/Magento\Framework\Config\Dom\ValidationExceptionhandling that turned an invalid design configuration into an admin error message was moved toMagento\Theme\Plugin\AbstractDesignLoaderPluginand is shared by all three plugins, so the behavior is identical no matter which part fails.LoadDesignPlugin's public constructor signature is unchanged.Scope note: the
designLoaderplugin onActionInterfaceis declared only inTheme/etc/frontend/di.xmlandTheme/etc/adminhtml/di.xml.webapi_rest,webapi_soapandgraphqlare out of scope — the plugin was never declared there (GraphQL has its ownMagento\CatalogGraphQl\Plugin\DesignLoader).Fixed Issues (if relevant)
Manual testing scenarios (*)
ValidationExceptionand confirm the admin still renders with the error message added, instead of a fatal error.translationLoaderanddesignChangeLoaderdisabled, and confirm it executes without loading translations (verify viaMagento\Framework\TranslateInterfacenot being populated, or via profilerload_area:frontend.translatedisappearing from the profile) while design-dependent code still works.Contribution checklist (*)