GridStackFormatterViewTrait.php in GridStack 8.2
File
src/Plugin/Field/FieldFormatter/GridStackFormatterViewTrait.php
View source
<?php
namespace Drupal\gridstack\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldItemListInterface;
trait GridStackFormatterViewTrait {
public function commonViewElements(FieldItemListInterface $items, $langcode, array $entities = [], array $settings = []) {
$settings = array_merge($this
->buildSettings(), $settings);
$settings['langcode'] = $langcode;
$build = [
'settings' => $settings,
];
$entities = empty($entities) ? [] : array_values($entities);
$this->formatter
->preBuildElements($build, $items, $entities);
$elements = $entities ?: $items;
$this
->buildElements($build, $elements, $langcode);
$this->formatter
->postBuildElements($build, $items, $entities);
return $this->manager
->build($build);
}
}