SerialDefaultFormatter.php in Serial Field 8
File
src/Plugin/Field/FieldFormatter/SerialDefaultFormatter.php
View source
<?php
namespace Drupal\serial\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Field\FieldItemListInterface;
class SerialDefaultFormatter extends FormatterBase {
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = [];
foreach ($items as $delta => $item) {
$source = [
'#theme' => 'serial_default',
'#serial_id' => $item->value,
];
$elements[$delta] = [
'#markup' => \Drupal::service('renderer')
->renderPlain($source),
];
}
return $elements;
}
}