You are here

public function GridStackManager::fieldFormatterInfoAlter in GridStack 8

Implements hook_field_formatter_info_alter().

File

src/GridStackManager.php, line 648

Class

GridStackManager
Implements GridStackManagerInterface.

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 refactor or drop for blazy 2.x.
  if ($this
    ->getModuleHandler()
    ->moduleExists('video_embed_media')) {
    $info['gridstack_file'] = $common + [
      'id' => 'gridstack_file',
      'label' => $this
        ->t('GridStack Image with Media'),
      'description' => $this
        ->t('Display the images associated to VEM/ME as a simple mix of GridStack image/video.'),
      'class' => 'Drupal\\gridstack\\Plugin\\Field\\FieldFormatter\\GridStackFileFormatter',
      'field_types' => [
        'entity_reference',
        'image',
      ],
    ];
    $info['gridstack_media'] = $common + [
      'id' => 'gridstack_media',
      'label' => $this
        ->t('GridStack Media'),
      'description' => $this
        ->t('Display the VEM/ME as a simple mix of GridStack image/video.'),
      'class' => 'Drupal\\gridstack\\Plugin\\Field\\FieldFormatter\\GridStackMediaFormatter',
      'field_types' => [
        'entity_reference',
      ],
    ];
  }
  if (function_exists('paragraphs_theme')) {
    $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',
      ],
    ];
  }
}