abstract class SlickEntityFormatterBase in Slick Carousel 8
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldFormatter/SlickEntityFormatterBase.php \Drupal\slick\Plugin\Field\FieldFormatter\SlickEntityFormatterBase
- 7.3 src/Plugin/Field/FieldFormatter/SlickEntityFormatterBase.php \Drupal\slick\Plugin\Field\FieldFormatter\SlickEntityFormatterBase
Base class for slick entity reference formatters without field details.
Hierarchy
- class \Drupal\slick\Plugin\Field\FieldFormatter\SlickEntityFormatterBase extends \Drupal\blazy\Dejavu\BlazyEntityBase implements ContainerFactoryPluginInterface uses SlickFormatterTrait
Expanded class hierarchy of SlickEntityFormatterBase
See also
\Drupal\slick_paragraphs\Plugin\Field\FieldFormatter
File
- src/
Plugin/ Field/ FieldFormatter/ SlickEntityFormatterBase.php, line 20
Namespace
Drupal\slick\Plugin\Field\FieldFormatterView source
abstract class SlickEntityFormatterBase extends BlazyEntityBase implements ContainerFactoryPluginInterface {
use SlickFormatterTrait;
/**
* The logger factory.
*
* @var \Drupal\Core\Logger\LoggerChannelFactoryInterface
*/
protected $loggerFactory;
/**
* Constructs a SlickMediaFormatter instance.
*/
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, LoggerChannelFactoryInterface $logger_factory, SlickFormatterInterface $formatter, SlickManagerInterface $manager) {
parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
$this->loggerFactory = $logger_factory;
$this->formatter = $formatter;
$this->manager = $manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($plugin_id, $plugin_definition, $configuration['field_definition'], $configuration['settings'], $configuration['label'], $configuration['view_mode'], $configuration['third_party_settings'], $container
->get('logger.factory'), $container
->get('slick.formatter'), $container
->get('slick.manager'));
}
/**
* Returns the blazy manager.
*/
public function blazyManager() {
return $this->formatter;
}
/**
* {@inheritdoc}
*/
public static function defaultSettings() {
$settings = SlickDefault::baseSettings();
$settings['view_mode'] = '';
return $settings;
}
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$entities = $this
->getEntitiesToView($items, $langcode);
// Early opt-out if the field is empty.
if (empty($entities)) {
return [];
}
// Collects specific settings to this formatter.
$settings = $this
->getSettings();
// Asks for Blazy to deal with iFrames, and mobile-optimized lazy loading.
$settings['blazy'] = TRUE;
$settings['plugin_id'] = $this
->getPluginId();
$settings['vanilla'] = TRUE;
$build = [
'settings' => $settings,
];
$this->formatter
->buildSettings($build, $items);
// Build the elements.
$this
->buildElements($build, $entities, $langcode);
return $this
->manager()
->build($build);
}
/**
* {@inheritdoc}
*/
public function getScopedFormElements() {
return [
'namespace' => 'slick',
'no_layouts' => TRUE,
] + parent::getScopedFormElements();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SlickEntityFormatterBase:: |
protected | property | The logger factory. | |
SlickEntityFormatterBase:: |
public | function | Returns the blazy manager. | |
SlickEntityFormatterBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
SlickEntityFormatterBase:: |
public static | function | ||
SlickEntityFormatterBase:: |
public | function | ||
SlickEntityFormatterBase:: |
public | function | ||
SlickEntityFormatterBase:: |
public | function | Constructs a SlickMediaFormatter instance. | |
SlickFormatterTrait:: |
protected | property | The slick field formatter manager. | |
SlickFormatterTrait:: |
protected | property | The slick field formatter manager. | |
SlickFormatterTrait:: |
public | function | Returns the slick admin service shortcut. | |
SlickFormatterTrait:: |
public | function | Returns the slick field formatter service. | |
SlickFormatterTrait:: |
public static | function | 1 | |
SlickFormatterTrait:: |
public | function | Returns the slick service. | |
SlickFormatterTrait:: |
public | function |