IframeOnlyFormatter.php in Iframe 8.2
File
src/Plugin/Field/FieldFormatter/IframeOnlyFormatter.php
View source
<?php
namespace Drupal\iframe\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Render\Markup;
class IframeOnlyFormatter extends IframeDefaultFormatter {
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = [];
foreach ($items as $delta => $item) {
if (empty($item->url)) {
continue;
}
if (!(property_exists($item, 'title') && $item->title !== null)) {
$item->title = '';
}
$elements[$delta] = self::iframeIframe('', $item->url, $item);
if (isset($settings['tokensupport']) && $settings['tokensupport']) {
$elements[$delta]['cache'] = [
'max-age' => 0,
];
}
}
return $elements;
}
}