You are here

public function ExampleEntityExtraFieldInfoSubscribers::fieldInfo in Hook Event Dispatcher 8

Entity extra field info.

Parameters

\Drupal\hook_event_dispatcher\Event\EntityExtra\EntityExtraFieldInfoEvent $event: The event.

File

src/Example/ExampleEntityExtraFieldInfoSubscribers.php, line 30

Class

ExampleEntityExtraFieldInfoSubscribers
Class ExampleEntityExtraFieldInfoSubscribers.

Namespace

Drupal\hook_event_dispatcher\Example

Code

public function fieldInfo(EntityExtraFieldInfoEvent $event) {

  // Set the field info directly.
  $fieldInfo = [];
  $event
    ->setFieldInfo($fieldInfo);
  $entityType = 'node';
  $bundle = 'page';
  $fieldName = 'field_test';
  $testFieldInfo = [];

  // Add a single display info.
  $event
    ->addDisplayFieldInfo($entityType, $bundle, $fieldName, $testFieldInfo);

  // Add a single form info.
  $event
    ->addFormFieldInfo($entityType, $bundle, $fieldName, $testFieldInfo);
}