You are here

field_count_formatter.module in Field Count Formatter 2.x

Same filename and directory in other branches
  1. 8 field_count_formatter.module
  2. 7 field_count_formatter.module

Adds all fields to the field types (the plugin definition does not allow this).

File

field_count_formatter.module
View source
<?php

/**
 * @file
 * Adds all fields to the field types (the plugin definition does not
 * allow this).
 */

/**
 * Implements hook_field_formatter_info_alter().
 */
function field_count_formatter_field_formatter_info_alter(array &$info) {

  // Adds the count formatter to all field types.
  if (isset($info['count'])) {
    $field_types = Drupal::service('plugin.manager.field.field_type')
      ->getDefinitions();
    $info['count']['field_types'] = array_keys($field_types);
  }
}