You are here

class WidgetMultivalueFormAlterEvent in Hook Event Dispatcher 3.x

Same name and namespace in other branches
  1. 8.2 modules/field_event_dispatcher/src/Event/Field/WidgetMultivalueFormAlterEvent.php \Drupal\field_event_dispatcher\Event\Field\WidgetMultivalueFormAlterEvent

Class WidgetMultivalueFormAlterEvent.

Hierarchy

Expanded class hierarchy of WidgetMultivalueFormAlterEvent

2 files declare their use of WidgetMultivalueFormAlterEvent
field_event_dispatcher.module in modules/field_event_dispatcher/field_event_dispatcher.module
Field event dispatcher submodule.
WidgetFormAlterEventTest.php in modules/field_event_dispatcher/tests/src/Unit/Field/WidgetFormAlterEventTest.php

File

modules/field_event_dispatcher/src/Event/Field/WidgetMultivalueFormAlterEvent.php, line 13

Namespace

Drupal\field_event_dispatcher\Event\Field
View source
class WidgetMultivalueFormAlterEvent extends Event implements EventInterface {

  /**
   * The field widget form elements.
   *
   * @var array
   */
  private $elements;

  /**
   * The form state.
   *
   * @var \Drupal\Core\Form\FormStateInterface
   */
  private $formState;

  /**
   * The context.
   *
   * @var array
   */
  private $context;

  /**
   * WidgetMultivalueFormAlterEvent constructor.
   *
   * @param array $elements
   *   The field widget form elements as constructed by
   *   \Drupal\Core\Field\WidgetBase::formMultipleElements().
   * @param \Drupal\Core\Form\FormStateInterface $formState
   *   The current state of the form.
   * @param array $context
   *   An associative array containing the following key-value pairs:
   *   - form: The form structure to which widgets are being attached. This may
   *     be a full form structure, or a sub-element of a larger form.
   *   - widget: The widget plugin instance.
   *   - items: The field values, as a
   *     \Drupal\Core\Field\FieldItemListInterface object.
   *   - default: A boolean indicating whether the form is being shown as a
   *     dummy form to set default values.
   */
  public function __construct(array &$elements, FormStateInterface $formState, array $context) {
    $this->elements =& $elements;
    $this->formState = $formState;
    $this->context = $context;
  }

  /**
   * Get the elements.
   *
   * @return array
   *   The elements.
   */
  public function &getElements() {
    return $this->elements;
  }

  /**
   * Get the form state.
   *
   * @return \Drupal\Core\Form\FormStateInterface
   *   The form state.
   */
  public function getFormState() {
    return $this->formState;
  }

  /**
   * Get the context.
   *
   * @return array
   *   The context.
   */
  public function getContext() {
    return $this->context;
  }

  /**
   * {@inheritdoc}
   */
  public function getDispatcherType() : string {
    return HookEventDispatcherInterface::WIDGET_MULTIVALUE_FORM_ALTER;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
WidgetMultivalueFormAlterEvent::$context private property The context.
WidgetMultivalueFormAlterEvent::$elements private property The field widget form elements.
WidgetMultivalueFormAlterEvent::$formState private property The form state.
WidgetMultivalueFormAlterEvent::getContext public function Get the context.
WidgetMultivalueFormAlterEvent::getDispatcherType public function Get the dispatcher type. Overrides EventInterface::getDispatcherType
WidgetMultivalueFormAlterEvent::getElements public function Get the elements.
WidgetMultivalueFormAlterEvent::getFormState public function Get the form state.
WidgetMultivalueFormAlterEvent::__construct public function WidgetMultivalueFormAlterEvent constructor.