SlickFormatterTrait.php in Slick Carousel 7.3
File
src/Plugin/Field/FieldFormatter/SlickFormatterTrait.php
View source
<?php
namespace Drupal\slick\Plugin\Field\FieldFormatter;
use Drupal\blazy\Plugin\Field\FieldFormatter\BlazyFormatterTrait;
use Drupal\slick\Form\SlickAdmin;
trait SlickFormatterTrait {
use BlazyFormatterTrait;
public function admin() {
if (!isset($this->admin)) {
$this->admin = new SlickAdmin($this->manager);
}
return $this->admin;
}
public function viewElements($items, $entity) {
$entities = $this
->getEntitiesToView($items);
if (empty($entities)) {
return [];
}
$this->entity = $entity;
$settings = $this
->buildSettings();
$build = [
'settings' => $settings,
];
$this
->formatter()
->preBuildElements($build, $entities, $entity);
$this
->buildElements($build, $entities);
$this
->formatter()
->postBuildElements($build, $entities, $entity);
$element = $this
->manager()
->build($build);
return $element;
}
}