Problem/Motivation
Sometimes we want to move a class from one place to a different place. An example is in #3502602: Remove non-formatter plugins out of the file field formatter directory.
There are two solutions we've used in the past:
1. Leave the old class in place, usually extending the new class, add @deprecated and trigger a deprecation. When we want to move something to avoid it being scanned for discovery, this does not help us until the next major release.
2. Add a call to class_alias - this has to be manually specified in boostrap.inc and can never be removed.
I think we might be able to handle both deprecation and aliasing in a classloader.
Steps to reproduce
Proposed resolution
Something like:
1. Create a new classloader
2. This classloader allows a $movedClasses array to be populated via a setter.
3. The moved classes array is keyed by the moved class, the value is an array of the new classname, the deprecated from version, the removed version (latter two could be optional).
4. in DrupalKernel, register this as an extra classloader, it should run after the composer classloader so it has zero runtime overhead.
5. When the composer classloader can't find a class, PHP falls back to our classloader. Our classloader checks the $movedClasses property, if the class is in there, it calls class_alias($old_class, $new_class, TRUE);
If this works, we could then look at populating the moved classes array, potentially from a container parameter so that it's possible for core and contrib modules to add to it.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
You have been blocked because we believe you are using automation tools to browse the website.
This may happen as a result of the following:
If you think you have been blocked by mistake, please contact help@drupal.org with the reference ID below.
Reference ID: #6f7c3fd2-f60f-11ef-8a3e-e2eeebf673b1
| # | Наименование новости | Тональность | Информативность | Дата публикации |
|---|---|---|---|---|
| 1 | Разработан метод "печати" узоров на пленках из нанотрубок | 0 | 8.98 | 25-08-2026 |