FlexsliderFormatter.php in Flex Slider 8.2
File
flexslider_fields/src/Plugin/Field/FieldFormatter/FlexsliderFormatter.php
View source
<?php
namespace Drupal\flexslider_fields\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\image\Plugin\Field\FieldFormatter\ImageFormatter;
class FlexsliderFormatter extends ImageFormatter {
use FlexsliderFormatterTrait;
use FlexsliderImageFormatterTrait;
public static function defaultSettings() {
return parent::defaultSettings() + self::getDefaultSettings() + self::getDefaultImageSettings();
}
public function settingsSummary() {
return array_merge(parent::settingsSummary(), $this
->buildSettingsSummary());
}
public function settingsForm(array $form, FormStateInterface $form_state) {
$element = $this
->buildSettingsForm();
$element = array_merge($element, parent::settingsForm($form, $form_state));
$element['image_link']['#access'] = FALSE;
if (!empty($this
->getSettings())) {
$element += $this
->captionSettings($this, $this->fieldDefinition);
}
return $element;
}
public function viewElements(FieldItemListInterface $items, $langcode) {
$images = parent::viewElements($items, $langcode);
$elements[] = $this
->viewImages($images, $this
->getSettings());
return $elements;
}
public static function isApplicable(FieldDefinitionInterface $field_definition) {
return parent::isApplicable($field_definition) && $field_definition
->getFieldStorageDefinition()
->isMultiple();
}
public function calculateDependencies() {
return parent::calculateDependencies() + $this
->getOptionsetDependencies();
}
public function onDependencyRemoval(array $dependencies) {
$changed = parent::onDependencyRemoval($dependencies);
if ($this
->optionsetDependenciesDeleted($dependencies)) {
$changed = TRUE;
}
return $changed;
}
}