ExampleFormattedField.php in Extra Field 8.2
File
modules/extra_field_example/src/Plugin/ExtraField/Display/ExampleFormattedField.php
View source
<?php
namespace Drupal\extra_field_example\Plugin\ExtraField\Display;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\extra_field\Plugin\ExtraFieldDisplayFormattedBase;
class ExampleFormattedField extends ExtraFieldDisplayFormattedBase {
use StringTranslationTrait;
public function getLabel() {
return $this
->t('Three items');
}
public function getLabelDisplay() {
return 'above';
}
public function viewElements(ContentEntityInterface $entity) {
return [
[
'#markup' => 'One',
],
[
'#markup' => 'Two',
],
[
'#markup' => 'Three',
],
];
}
}