InteractiveLinkFormatter.php in Facebook Instant Articles 8.2
File
src/Plugin/Field/FieldFormatter/InteractiveLinkFormatter.php
View source
<?php
namespace Drupal\fb_instant_articles\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldItemInterface;
use Drupal\Core\Form\FormStateInterface;
use Facebook\InstantArticles\Elements\Interactive;
class InteractiveLinkFormatter extends InteractiveFormatter {
public static function defaultSettings() {
$default_settings = parent::defaultSettings();
unset($default_settings['source_type']);
return $default_settings;
}
public function settingsForm(array $form, FormStateInterface $form_state) {
$element = parent::settingsForm($form, $form_state);
unset($element['source_type']);
return $element;
}
public function settingsSummary() {
$summary = [];
if ($width = $this
->getSetting('width')) {
$summary[] = $this
->t('Width: @width', [
'@width' => $width,
]);
}
if ($height = $this
->getSetting('height')) {
$summary[] = $this
->t('Height: @height', [
'@height' => $height,
]);
}
$margin = $this
->getSetting('margin');
$summary[] = $this
->t('Margin setting: @margin', [
'@margin' => $margin === Interactive::NO_MARGIN ? $this
->t('No margin') : $this
->t('Column width'),
]);
return $summary;
}
protected function getItemValue(FieldItemInterface $item) {
return $item->uri;
}
}