public function BlazyFormatterViewTrait::commonViewElements in Blazy 8.2
Returns similar view elements.
4 calls to BlazyFormatterViewTrait::commonViewElements()
- BlazyFormatterBlazy::viewElements in src/
Plugin/ Field/ FieldFormatter/ BlazyFormatterBlazy.php - Builds a renderable array for a field value.
- BlazyMediaFormatter::viewElements in src/
Plugin/ Field/ FieldFormatter/ BlazyMediaFormatter.php - Builds a renderable array for a field value.
- BlazyOEmbedFormatter::viewElements in src/
Plugin/ Field/ FieldFormatter/ BlazyOEmbedFormatter.php - Builds a renderable array for a field value.
- BlazyVideoFormatter::viewElements in src/
Plugin/ Field/ FieldFormatter/ BlazyVideoFormatter.php - Builds a renderable array for a field value.
File
- src/
Plugin/ Field/ FieldFormatter/ BlazyFormatterViewTrait.php, line 15
Class
- BlazyFormatterViewTrait
- A Trait common for all blazy formatters.
Namespace
Drupal\blazy\Plugin\Field\FieldFormatterCode
public function commonViewElements(FieldItemListInterface $items, $langcode, array $entities = [], array $settings = []) {
// Collects specific settings to this formatter.
$settings = array_merge($this
->buildSettings(), $settings);
$settings['langcode'] = $langcode;
// Build the settings.
$build = [
'settings' => $settings,
];
// Modifies settings before building elements.
$entities = empty($entities) ? [] : array_values($entities);
$this->formatter
->preBuildElements($build, $items, $entities);
// Build the elements.
$elements = $entities ?: $items;
$this
->buildElements($build, $elements, $langcode);
// Modifies settings post building elements.
$this->formatter
->postBuildElements($build, $items, $entities);
// Pass to manager for easy updates to all Blazy formatters.
return $this->formatter
->build($build);
}