trait SlickFormatterTrait in Slick Carousel 7.3
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldFormatter/SlickFormatterTrait.php \Drupal\slick\Plugin\Field\FieldFormatter\SlickFormatterTrait
- 8 src/Plugin/Field/FieldFormatter/SlickFormatterTrait.php \Drupal\slick\Plugin\Field\FieldFormatter\SlickFormatterTrait
A Trait common for slick formatters.
Hierarchy
- trait \Drupal\slick\Plugin\Field\FieldFormatter\SlickFormatterTrait uses BlazyFormatterTrait
File
- src/
Plugin/ Field/ FieldFormatter/ SlickFormatterTrait.php, line 11
Namespace
Drupal\slick\Plugin\Field\FieldFormatterView source
trait SlickFormatterTrait {
use BlazyFormatterTrait;
/**
* Returns the slick admin service.
*/
public function admin() {
if (!isset($this->admin)) {
$this->admin = new SlickAdmin($this->manager);
}
return $this->admin;
}
/**
* {@inheritdoc}
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BlazyFormatterTrait:: |
protected | property | The blazy-related formatter service. | |
BlazyFormatterTrait:: |
protected | property | The blazy field formatter manager. | |
BlazyFormatterTrait:: |
public | function | Returns the blazy-related formatter. | |
BlazyFormatterTrait:: |
public | function | Returns the blazy service. | |
BlazyFormatterTrait:: |
public | function | ||
SlickFormatterTrait:: |
public | function | Returns the slick admin service. | |
SlickFormatterTrait:: |
public | function | 1 |