Improve deprecated hook_event_dispatcher documentation

Created on 15 February 2023, over 1 year ago
Updated 16 August 2023, 11 months ago

Problem/Motivation

In response of FieldHookEvents::WIDGET_SINGLE_ELEMENT_FORM_ALTER not found πŸ› FieldHookEvents::WIDGET_SINGLE_ELEMENT_FORM_ALTER not found Closed: works as designed

Steps to reproduce

Add FieldHookEvents::WIDGET_SINGLE_ELEMENT_FORM_ALTER to the function getSubscribedEvents() without enable the submodule field_event_dispatcher.

  public static function getSubscribedEvents() {
    return [
      FieldHookEvents::WIDGET_SINGLE_ELEMENT_FORM_ALTER => 'fieldWidgetFormAlter',
    ];
  }

Proposed resolution

Add in HookEventDispatcherInterface on every deprecated const :

  /**
   * Alter forms for field widgets provided by other modules.
   *
   * @Event
   *
   * @deprecated in hook_event_dispatcher:3.0.0-rc1 and is removed from
   *   hook_event_dispatcher:4.0.0. Use
   *   HookEventDispatcherInterface::WIDGET_SINGLE_ELEMENT_FORM_ALTER instead.
   *   Be sure than the field_event_dispatcher module is enable.
   *
   * @see https://www.drupal.org/node/3180429
   * @see field_event_dispatcher_field_widget_form_alter()
   * @see hook_field_widget_form_alter()
   *
   * @var string
   */
  public const WIDGET_FORM_ALTER = self::PREFIX . 'widget_form.alter';

Add on the Readme add :

You can find an example on how to use each Event in src/Example.
You must enable submodules to use their events

πŸ“Œ Task
Status

Active

Version

3.3

Component

Code

Created by

πŸ‡«πŸ‡·France guisharko

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @guisharko
  • πŸ‡¨πŸ‡΄Colombia yovanny.gomez.oyola

    Hi,

    This is a topic that is not very clear when changing to the module version 4.0.0-rc1. I have downloaded the mentioned version and the WIDGET_FORM_ALTER constant is no longer found, so an error is generated in Drupal.

    It's a little hard to know which constant to use now. I think there is a lack of documentation about it.

    It is not clear whether to use WIDGET_SINGLE_ELEMENT_FORM_ALTER or WIDGET_COMPLETE_FORM_ALTER

    Regards,

Production build 0.69.0 2024