You are here

public function FormatterPlugin::formatterInfo in Blazy 7

Implements hook_field_formatter_info().

1 call to FormatterPlugin::formatterInfo()
FormatterPlugin::getActiveFormatter in src/Plugin/Field/FieldFormatter/FormatterPlugin.php
Return the uncached formatter based on the field type.

File

src/Plugin/Field/FieldFormatter/FormatterPlugin.php, line 41

Class

FormatterPlugin
Blazy formatter plugin initializer.

Namespace

Drupal\blazy\Plugin\Field\FieldFormatter

Code

public function formatterInfo() {
  if (!isset($this->formatterInfo)) {
    $formatters = [];
    foreach ([
      'file',
      'image',
      'text',
    ] as $type) {
      $class = 'Drupal\\blazy\\Plugin\\Field\\FieldFormatter\\Blazy' . ucwords($type) . 'Formatter';
      $formatters['blazy_' . $type] = [
        'label' => $type == 'text' ? t('Blazy grid') : t('Blazy'),
        'class' => $class,
        'field types' => $type == 'text' ? BlazyDefault::TEXTS : [
          $type,
        ],
        'settings' => $class::defaultSettings(),
      ];
    }
    $this->formatterInfo = $formatters;
  }
  return $this->formatterInfo;
}