abstract class SlickFormatterBase in Slick Carousel 7.3
Base class for slick image and file entity (Media) formatters.
Hierarchy
- class \Drupal\blazy\Plugin\Field\FieldFormatter\FormatterBase implements FormatterInterface
- class \Drupal\blazy\Plugin\Field\FieldFormatter\BlazyFormatterBase
- class \Drupal\slick\Plugin\Field\FieldFormatter\SlickFormatterBase
- class \Drupal\blazy\Plugin\Field\FieldFormatter\BlazyFormatterBase
Expanded class hierarchy of SlickFormatterBase
See also
Drupal\slick\Plugin\Field\SlickFileFormatter
Drupal\slick\Plugin\Field\SlickImageFormatter
File
- src/
Plugin/ Field/ FieldFormatter/ SlickFormatterBase.php, line 16
Namespace
Drupal\slick\Plugin\Field\FieldFormatterView source
abstract class SlickFormatterBase extends BlazyFormatterBase {
/**
* Constructs a SlickImageFormatter instance.
*/
public function __construct($plugin_id, $field, $instance, SlickFormatterInterface $formatter, SlickManagerInterface $manager) {
parent::__construct($plugin_id, $field, $instance);
$this->formatter = $formatter;
$this->manager = $manager;
}
/**
* {@inheritdoc}
*/
public static function defaultSettings() {
return SlickDefault::imageSettings();
}
/**
* Build the slick carousel elements.
*/
public function buildElements(array &$build, $items) {
$settings = $build['settings'];
$item_id = $settings['item_id'];
foreach ($items as $delta => $item) {
$settings['delta'] = $delta;
$settings['type'] = isset($item->type) ? $item->type : 'image';
$settings['uri'] = $item->uri;
$element = [
'item' => $item,
'settings' => $settings,
'content' => [],
];
// Provide advanced functionality to build fieldable elements.
$this
->buildElement($element, $item, $delta);
// Build individual slick item.
$build['items'][$delta] = $element;
// Build individual slick thumbnail.
if (!empty($settings['nav'])) {
$thumb = [
'settings' => $element['settings'],
];
// Thumbnail usages: asNavFor pagers, dot, arrows, photobox thumbnails.
$thumb[$item_id] = empty($settings['thumbnail_style']) ? [] : $this
->formatter()
->getThumbnail($element['settings'], $element['item']);
$thumb['caption'] = empty($settings['thumbnail_caption']) ? [] : array_filter($this
->getCaption($item, $settings['thumbnail_caption'], $settings));
$build['thumb']['items'][$delta] = $thumb;
}
}
}
/**
* Build caption element if so configured can be used for thumbnail caption.
*/
protected abstract function getCaption($entity, $field_name, $settings);
/**
* {@inheritdoc}
*/
public function getScopedFormElements() {
return [
'namespace' => 'slick',
'nav' => TRUE,
'thumb_captions' => [
'title' => t('Title'),
'alt' => t('Alt'),
],
'thumb_positions' => TRUE,
] + parent::getScopedFormElements();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BlazyFormatterBase:: |
abstract public | function | Returns the blazy admin service for blazy-related module. | 1 |
BlazyFormatterBase:: |
abstract public | function | Build individual item if so configured such as for file entity goodness. | 2 |
BlazyFormatterBase:: |
protected | function | Converts $items array to object for easy D8 -> D7 backports. | 1 |
BlazyFormatterBase:: |
public | function |
Returns required form elements for the current formatter. Overrides FormatterBase:: |
2 |
BlazyFormatterBase:: |
public | function |
Implements hook_field_formatter_settings_form(). Overrides FormatterBase:: |
1 |
BlazyFormatterBase:: |
public | function |
Implements hook_field_formatter_settings_summary(). Overrides FormatterBase:: |
|
FormatterBase:: |
protected | property | The blazy-related admin formatter service. | |
FormatterBase:: |
protected | property | Whether default settings have been merged into the current $settings. | |
FormatterBase:: |
protected | property | The field definition. | |
FormatterBase:: |
protected | property | The field display. | |
FormatterBase:: |
protected | property | The field instance. | |
FormatterBase:: |
protected | property | The form settings. | |
FormatterBase:: |
protected | property | True if the field cardinality equals -1. | |
FormatterBase:: |
protected | property | The known hard-coded entities. | |
FormatterBase:: |
protected | property | The langcode. | |
FormatterBase:: |
protected | property | The blazy formatter plugin id. | |
FormatterBase:: |
protected | property | The formatter settings. | |
FormatterBase:: |
protected | property | The view mode. | |
FormatterBase:: |
public | function | Builds the settings. | 1 |
FormatterBase:: |
public | function | Implements hook_field_formatter_settings_form(). | |
FormatterBase:: |
public | function | ||
FormatterBase:: |
public | function | Gets html settings. | |
FormatterBase:: |
public | function | Gets formatter plugin id. | |
FormatterBase:: |
public | function | ||
FormatterBase:: |
public | function | Gets formatter settings. | |
FormatterBase:: |
protected | function | Merges default settings values into $settings. | |
FormatterBase:: |
public | function | Sets html settings. | |
FormatterBase:: |
public | function | ||
FormatterBase:: |
public | function | Sets formatter settings. | |
FormatterBase:: |
protected | function | Setup common variables across different hooks. | |
FormatterBase:: |
public | function | Implements hook_field_formatter_view(). | |
FormatterBase:: |
abstract public | function |
Implements hook_field_formatter_view(). Overrides FormatterInterface:: |
2 |
SlickFormatterBase:: |
public | function | Build the slick carousel elements. | 1 |
SlickFormatterBase:: |
public static | function |
Returns default settings. Overrides BlazyFormatterBase:: |
1 |
SlickFormatterBase:: |
abstract protected | function | Build caption element if so configured can be used for thumbnail caption. | 2 |
SlickFormatterBase:: |
public | function |
Defines the scope for the form elements. Overrides BlazyFormatterBase:: |
1 |
SlickFormatterBase:: |
public | function |
Constructs a SlickImageFormatter instance. Overrides FormatterBase:: |