-
Improvement
-
Resolution: Fixed
-
Critical
-
4.4
-
MOODLE_404_STABLE
-
MOODLE_404_STABLE
-
MDL-81011-main -
When writing a hook, you are encouraged to make it a described hook to add an untranslated description and set of tags.
Really though, that information is metadata and we require a whole heap of unnecessary boilerplate just for those.
Enter... attributes
#[\core\attribute\label('Allows plugins to insert nodes into site primary navigation')]
|
#[\core\attribute\tags('navigation')]
|
class primary_extend implements \Psr\EventDispatcher\StoppableEventInterface {
|
// ...
|
}
|
We can add attributes as an optional alternative to implementing the described_hook interface and it drastically reduces boilerplate.
In time I'd like to make greater use of attributes such as these.