Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293784

Drop $method parameter from Preprocess and FormAlter attributes, allow only on methods

$
0
0

Problem/Motivation

The #[Hook] attribute can be used on classes and methods.
When used on class level, it can either specify a method name, or it will apply to the __invoke() method.

There is hardly ever a technical reason why one would use the attribute on a class, instead of a method.
The only reason people would do this is personal taste.

As such, this provides an unnecessary alternative to achieve the same thing.
The cost is added complexity in the Hook class, where we now have to explain the different cases.

Steps to reproduce

Proposed resolution

We cannot remove this functionality from the existing #[Hook] class.
Currently these are Preprocess and FormAlter.
But we can remove it from any new attributes that extend Hook, which are not in any stable release yet.

The MR will include changes from #3523109: Rethink #[Hook] attribute inheritance which shall be seen as a dependency of this issue.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 293784

Trending Articles