FlexsliderResponsiveFormatter.php in Flex Slider 8.2
File
flexslider_fields/src/Plugin/Field/FieldFormatter/FlexsliderResponsiveFormatter.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\responsive_image\Plugin\Field\FieldFormatter\ResponsiveImageFormatter;
class FlexsliderResponsiveFormatter extends ResponsiveImageFormatter {
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($this);
$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);
return $this
->viewImages($images, $this
->getSettings());
}
public static function isApplicable(FieldDefinitionInterface $field_definition) {
if (\Drupal::moduleHandler()
->moduleExists('responsive_image')) {
return parent::isApplicable($field_definition) && $field_definition
->getFieldStorageDefinition()
->isMultiple();
}
return FALSE;
}
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;
}
}