public function SlickFormatterPlugin::formatterInfo in Slick Carousel 7.3
Implements hook_field_formatter_info().
Overrides FormatterPlugin::formatterInfo
File
- src/
Plugin/ Field/ FieldFormatter/ SlickFormatterPlugin.php, line 34
Class
- SlickFormatterPlugin
- Slick formatter initializer.
Namespace
Drupal\slick\Plugin\Field\FieldFormatterCode
public function formatterInfo() {
if (!isset($this->formatterInfo)) {
$formatters = [];
$fields = SlickDefault::FIELDS;
// The new formatter is now suffixed with field type to have a class each.
foreach ($fields as $type) {
$name = $type == 'text' ? 'Text' : ($type == 'field_collection' ? 'FieldCollection' : ucwords($type));
$class = 'Drupal\\slick\\Plugin\\Field\\FieldFormatter\\Slick' . $name . 'Formatter';
$formatters['slick_' . $type] = [
'label' => t('Slick Carousel'),
'class' => $class,
'field types' => $type == 'text' ? SlickDefault::TEXTS : [
$type,
],
'settings' => $class::defaultSettings(),
];
}
// @todo remove deprecated formatter post release on succesful update.
if ($this->manager
->config('deprecated_formatter', TRUE, 'slick.settings')) {
array_pop($fields);
$formatters['slick'] = [
'label' => t('Slick Carousel (deprecated)'),
'field types' => $fields,
'settings' => SlickDefault::extendedSettings(),
];
}
$this->formatterInfo = $formatters;
}
return $this->formatterInfo;
}