public function SlickFormatterTrait::viewElements in Slick Carousel 7.3
1 method overrides SlickFormatterTrait::viewElements()
- SlickTextFormatter::viewElements in src/
Plugin/ Field/ FieldFormatter/ SlickTextFormatter.php - Implements hook_field_formatter_view().
File
- src/
Plugin/ Field/ FieldFormatter/ SlickFormatterTrait.php, line 28
Class
- SlickFormatterTrait
- A Trait common for slick formatters.
Namespace
Drupal\slick\Plugin\Field\FieldFormatterCode
public function viewElements($items, $entity) {
$entities = $this
->getEntitiesToView($items);
// Early opt-out if the field is empty.
if (empty($entities)) {
return [];
}
// Collects specific settings to this formatter.
$this->entity = $entity;
$settings = $this
->buildSettings();
$build = [
'settings' => $settings,
];
// Modifies settings before building elements.
$this
->formatter()
->preBuildElements($build, $entities, $entity);
// Build the elements.
$this
->buildElements($build, $entities);
// Modifies settings post building elements.
$this
->formatter()
->postBuildElements($build, $entities, $entity);
// If using 0, or directly passed like D8, taken over by theme_field().
$element = $this
->manager()
->build($build);
return $element;
}