Stop using getService for lexicon, registry, error, smarty, mail, and hashing - #21
Open
Ibochkarev wants to merge 6 commits into
Open
Stop using getService for lexicon, registry, error, smarty, mail, and hashing#21Ibochkarev wants to merge 6 commits into
Ibochkarev wants to merge 6 commits into
Conversation
Register modError during initialize next to registry (lexicon already comes from _initCulture). Replace core/manager getService call sites for those three services with the DI container or synced properties. Part of the series planned on modxcms#15986 (tier 1).
Register hashing eagerly and mail/smarty as lazy shared DI services during initialize, then replace remaining core/manager call sites so tiers 1–2 of modxcms#15986 ship in one PR.
Extract _registerCoreServices, add getSmarty/getMail/getManagerTemplatePath, drop duplicated smarty bootstraps and dead widget ensures, and simplify Reload registry handling.
Do not pre-register mail/smarty (keeps getService param+property sync), ensure widgets call getSmarty(), sync properties in modX::getService, and resolve hashing on plain xPDO without touching a missing property.
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.
Что сделано
getService()deprecated, но core и менеджер по-прежнему использовали его как lazy-фабрику для встроенных сервисов. Этот PR заканчивает tiers 1–2 из плана modxcms#15986: перестать вызывать его для шести имён вcore/srcиmanager.Эта работа лежит на стеке MAB-03 (xPDO 3 через Composer, autoloading, меньше map-эры привычек). Здесь тот же направление для runtime-сервисов: регистрировать их в DI-контейнере / аксессорах вместо старого xPDO service locator.
Tier 1 —
lexicon,registry,errorregisterCoreServices()регистрируетregistry,errorиhashingво времяinitialize()(lexiconуже приходит из_initCulture).$modx->services->get(…)или синхронизированные свойства$modx->registry/$modx->lexicon/$modx->error.Tier 2 —
smarty,mail,hashinghashingeager (пути паролей нуждаются в нём).getSmarty()/getMail()/getManagerTemplatePath()— канонические аксессоры; smarty/mail регистрируются при первом использовании.getSmarty($path).modX::getService()по-прежнему работает для экстра/тестов и синхронизирует$modx->$name, когда сервис уже в контейнере.Grep-gate для этих шести имён под
core/srcиmanagerпуст.Как проверить
rg "getService\s*\(\s*['\"](lexicon|registry|error|smarty|mail|hashing)" core/src manager→ пустоСвязанные
fileHandler/phpthumb/archive/translit, extension packages, затем давление на самgetServiceСовместимость
Экстра, всё ещё вызывающие
getService()для этих имён, продолжают работать. Core предпочитает аксессоры и container/$modx->*свойства после нормализации.Оригинал: modxcms#16985