You are here

class EntityExtraFieldInfoEvent in Hook Event Dispatcher 3.x

Same name and namespace in other branches
  1. 8.2 modules/core_event_dispatcher/src/Event/Entity/EntityExtraFieldInfoEvent.php \Drupal\core_event_dispatcher\Event\Entity\EntityExtraFieldInfoEvent

Class EntityExtraFieldInfoEvent.

Hierarchy

Expanded class hierarchy of EntityExtraFieldInfoEvent

3 files declare their use of EntityExtraFieldInfoEvent
core_event_dispatcher.module in modules/core_event_dispatcher/core_event_dispatcher.module
Core event dispatcher submodule.
EntityExtraEventTest.php in modules/core_event_dispatcher/tests/src/Unit/Entity/EntityExtraEventTest.php
ExampleEntityExtraFieldInfoSubscribers.php in examples/ExampleEntityExtraFieldInfoSubscribers.php

File

modules/core_event_dispatcher/src/Event/Entity/EntityExtraFieldInfoEvent.php, line 12

Namespace

Drupal\core_event_dispatcher\Event\Entity
View source
class EntityExtraFieldInfoEvent extends Event implements EventInterface {

  /**
   * Field info.
   *
   * @var array
   */
  private $fieldInfo = [];

  /**
   * Get the dispatcher type.
   *
   * @return string
   *   The dispatcher type.
   */
  public function getDispatcherType() : string {
    return HookEventDispatcherInterface::ENTITY_EXTRA_FIELD_INFO;
  }

  /**
   * Set the field info.
   *
   * @param array $fieldInfo
   *   Field info.
   */
  public function setFieldInfo(array $fieldInfo) : void {
    $this->fieldInfo = $fieldInfo;
  }

  /**
   * Get the field info.
   *
   * @return array
   *   Field info.
   */
  public function getFieldInfo() : array {
    return $this->fieldInfo;
  }

  /**
   * Add field info for a form display.
   *
   * @param string $entityType
   *   The entity type.
   * @param string $bundle
   *   The bundle.
   * @param string $fieldName
   *   The field name.
   * @param array $info
   *   The field info.
   */
  public function addDisplayFieldInfo(string $entityType, string $bundle, string $fieldName, array $info) : void {
    $this
      ->addFieldInfo($entityType, $bundle, $fieldName, $info, 'display');
  }

  /**
   * Add field info for a form display.
   *
   * @param string $entityType
   *   The entity type.
   * @param string $bundle
   *   The bundle.
   * @param string $fieldName
   *   The field name.
   * @param array $info
   *   The field info.
   */
  public function addFormFieldInfo(string $entityType, string $bundle, string $fieldName, array $info) : void {
    $this
      ->addFieldInfo($entityType, $bundle, $fieldName, $info, 'form');
  }

  /**
   * Add field info for a given type.
   *
   * @param string $entityType
   *   The entity type.
   * @param string $bundle
   *   The bundle.
   * @param string $fieldName
   *   The field name.
   * @param array $info
   *   The field info.
   * @param string $type
   *   The type.
   */
  private function addFieldInfo(string $entityType, string $bundle, string $fieldName, array $info, string $type) : void {
    $this->fieldInfo[$entityType][$bundle][$type][$fieldName] = $info;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityExtraFieldInfoEvent::$fieldInfo private property Field info.
EntityExtraFieldInfoEvent::addDisplayFieldInfo public function Add field info for a form display.
EntityExtraFieldInfoEvent::addFieldInfo private function Add field info for a given type.
EntityExtraFieldInfoEvent::addFormFieldInfo public function Add field info for a form display.
EntityExtraFieldInfoEvent::getDispatcherType public function Get the dispatcher type. Overrides EventInterface::getDispatcherType
EntityExtraFieldInfoEvent::getFieldInfo public function Get the field info.
EntityExtraFieldInfoEvent::setFieldInfo public function Set the field info.