Count.php in Field Count Formatter 8
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 array(
t('Displays the number of items/count.'),
);
}
public function viewElements(FieldItemListInterface $items, $langcode) {
return array(
array(
'#type' => 'markup',
'#markup' => $items
->count(),
),
);
}
}
Classes
Name |
Description |
Count |
Plugin implementation of the 'CountFormatter' formatter. |