Skip to content

Hooks and events

Hooks implemented

Implemented in moderation_note.module:

Hook Purpose
hook_entity_delete() When a moderation_note is deleted: delete its children. When another entity is deleted: delete all notes for that entity.
hook_menu_local_tasks_alter() On moderated entity routes: add “View notes” local task (via moderation_note.menu_count->contentLink()). Adds cache context user.permissions and cache tag moderation_note:{entity_type}:{entity_id}.
hook_toolbar_alter() Add “Assigned notes” link in user tray (via moderation_note.menu_count->assignedTo()). Cache context user; tag moderation_note:user:{uid}.
hook_preprocess_field() On supported field types: attach library moderation_note/main, data attributes for field ID and create capability, and note data via _moderation_note_attach_field_notes(). Skips computed fields.
hook_theme() Defines moderation_note, moderation_note__preview, mail_moderation_note.
hook_theme_suggestions_HOOK() moderation_note_theme_suggestions_moderation_note() — suggestion by view mode.
hook_mail() Builds subject/body for keys: insert, assign, resolve, re-open. Respects send_email config. See Email and notifications.
hook_entity_insert() moderation_note_moderation_note_insert(): send insert (and assign) mail; invalidate cache tags.
hook_entity_update() moderation_note_moderation_note_update(): send assign mail if assignee changed; send resolve/re-open mail if published changed (top-level only).
hook_entity_view_mode_info_alter() Adds view mode moderation_note.preview for entity type moderation_note.

URI callback

  • moderation_note_uri(ModerationNoteInterface $note): Returns URL to view the note in context (moderated entity with query open-moderation-note). Uses latest-version or canonical depending on pending revision.

Supported field types

Notes can be attached only to non-computed fields of these types:

Type
boolean
datetime
entity_reference_revisions
entity_reference
list_string
string_long
string
text_long
text_with_summary
text

Entity must be a content entity, latest revision, moderated, and not new. Entities referenced via entity reference revisions are not notable individually (see _moderation_note_access()).