Quantcast
Viewing all articles
Browse latest Browse all 295818

[meta] Standardize and clean up hook classes in core

Problem/Motivation

The conversion of core to use oop hooks was successful using rector, there are several tasks that need to be done.

Please provide suggestions.

Steps to reproduce

N/A

Proposed resolution

Grouping standards

Single hook classes
Certain hooks should be in a class by themselves.
These hooks should use the attribute on the Class instead of the method, the method needs to be __invoke in this case.
Hooks in this category:

  • help
  • theme
  • cron
  • add others

Grouped hook classes
Certain hook groups should be in a class together.
These hooks should use the attribute on the method.
Form hooks

  • form_alters
  • form_FORM_ID_alter
  • form_BASE_FORM_ID_alter

Theme suggestion hooks

  • theme_suggestions
  • theme_suggestions_alter

Entity action hooks

  • hook_entity_update
  • hook_ENTITY_TYPE_update

Token hooks

Views hooks

Additional groups to be suggested.

Remaining hooks
Remaining hooks should go in moduleHooks.php unless they need to be broken up for length.

Class naming standards

Single hooks classes should be named ModuleHook.php e.g. FileCron.php
Group hooks classes should be named ModuleGroupsHooks e.g. FileFormAlters.php
Remaining hooks should be named ModuleHooks e.g. FileHooks.php

Commenting standards

Recommendations welcome.

Method naming conventions

Recommendations welcome.

Remaining tasks

Create issues for each core module

User interface changes

N/A

Introduced terminology

N/A

API changes

Data model changes

N/A

Release notes snippet

N/A


Viewing all articles
Browse latest Browse all 295818


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>