FlickityEntityView.php in Flickity Carousel 8.2
File
modules/fields/src/Plugin/Field/FieldFormatter/FlickityEntityView.php
View source
<?php
namespace Drupal\flickity_fields\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceEntityFormatter;
use Drupal\Core\Form\FormStateInterface;
class FlickityEntityView extends EntityReferenceEntityFormatter {
public function settingsForm(array $form, FormStateInterface $form_state) {
return array(
'flickity_settings' => array(
'#title' => $this
->t('Flickity settings'),
'#type' => 'select',
'#options' => flickity_settings_list(),
'#default_value' => $this
->getSetting('flickity_settings'),
'#required' => TRUE,
),
) + parent::settingsForm($form, $form_state);
}
public static function defaultSettings() {
return array(
'flickity_settings' => 'default_group',
) + parent::defaultSettings();
}
public function settingsSummary() {
return parent::settingsSummary();
}
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = array(
'#theme' => 'flickity_entity_view',
'#children' => parent::viewElements($items, $langcode),
'#settings' => $this
->getSetting('flickity_settings'),
'#title' => $this->fieldDefinition
->getLabel(),
'#label_display' => $this->label,
);
return $elements;
}
}