Count.php in Field Count Formatter 2.x
File
src/Plugin/Field/FieldFormatter/Count.php
View source
<?php
namespace Drupal\field_count_formatter\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Field\FieldItemListInterface;
class Count extends FormatterBase {
public function settingsSummary() {
return [
$this
->t('Displays the number of items/count.'),
];
}
public function viewElements(FieldItemListInterface $items, $langcode) {
return [
[
'#markup' => $items
->count(),
],
];
}
}
Classes
Name |
Description |
Count |
Plugin implementation of the 'CountFormatter' formatter. |