You are here

class EntityExtraFieldInfoEvent in Hook Event Dispatcher 8

Class EntityExtraFieldInfoEvent.

Hierarchy

Expanded class hierarchy of EntityExtraFieldInfoEvent

3 files declare their use of EntityExtraFieldInfoEvent
EntityExtraEventTest.php in tests/src/Unit/EntityExtra/EntityExtraEventTest.php
ExampleEntityExtraFieldInfoSubscribers.php in src/Example/ExampleEntityExtraFieldInfoSubscribers.php
hook_event_dispatcher.module in ./hook_event_dispatcher.module
Hook event dispatcher module.

File

src/Event/EntityExtra/EntityExtraFieldInfoEvent.php, line 12

Namespace

Drupal\hook_event_dispatcher\Event\EntityExtra
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() {
    return HookEventDispatcherInterface::ENTITY_EXTRA_FIELD_INFO;
  }

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

  /**
   * Get the field info.
   *
   * @return array
   *   Field info.
   */
  public function getFieldInfo() {
    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($entityType, $bundle, $fieldName, array $info) {
    $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($entityType, $bundle, $fieldName, array $info) {
    $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($entityType, $bundle, $fieldName, array $info, $type) {
    $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.