You are here

public function GridStackHook::fieldFormatterInfoAlter in GridStack 8.2

Implements hook_field_formatter_info_alter().

File

src/GridStackHook.php, line 114

Class

GridStackHook
Provides GridStack utility methods for Drupal hooks.

Namespace

Drupal\gridstack

Code

public function fieldFormatterInfoAlter(array &$info) {
  $common = [
    'quickedit' => [
      'editor' => 'disabled',
    ],
    'provider' => 'gridstack',
  ];

  // Supports Media Entity via VEM within VEF if available.
  // @todo drop for blazy 2.x with core Media.
  if ($this->manager
    ->getModuleHandler()
    ->moduleExists('video_embed_media')) {
    $info['gridstack_file'] = $common + [
      'id' => 'gridstack_file',
      'label' => $this
        ->t('GridStack Image with VEF (deprecated)'),
      'description' => $this
        ->t('Display the images associated to VEM/ME as a simple mix of GridStack image/video (deprecated for GridStack Media).'),
      'class' => 'Drupal\\gridstack\\Plugin\\Field\\FieldFormatter\\GridStackFileFormatter',
      'field_types' => [
        'entity_reference',
        'image',
      ],
    ];
  }
  if ($this->manager
    ->getModuleHandler()
    ->moduleExists('paragraphs')) {
    $info['gridstack_paragraphs'] = $common + [
      'id' => 'gridstack_paragraphs',
      'label' => $this
        ->t('GridStack Paragraphs'),
      'description' => $this
        ->t('Display the Paragraphs as a GridStack.'),
      'class' => 'Drupal\\gridstack\\Plugin\\Field\\FieldFormatter\\GridStackParagraphsFormatter',
      'field_types' => [
        'entity_reference_revisions',
      ],
    ];
  }
}