Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x

IntegerFormatter.php

Namespace

Drupal\Core\Field\Plugin\Field\FieldFormatter

File

core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/IntegerFormatter.php

View source
<?php

namespace Drupal\Core\Field\Plugin\Field\FieldFormatter;

use Drupal\Core\Field\Attribute\FieldFormatter;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * Plugin implementation of the 'number_integer' formatter.
 *
 * The 'Default' formatter is different for integer fields on the one hand, and
 * for decimal and float fields on the other hand, in order to be able to use
 * different settings.
 */
class IntegerFormatter extends NumericFormatterBase {
    
    /**
     * {@inheritdoc}
     */
    public static function defaultSettings() {
        return [
            'thousand_separator' => '',
            'prefix_suffix' => TRUE,
        ] + parent::defaultSettings();
    }
    
    /**
     * {@inheritdoc}
     */
    protected function numberFormat($number) {
        return number_format($number, 0, '', $this->getSetting('thousand_separator'));
    }

}

Classes

Title Deprecated Summary
IntegerFormatter Plugin implementation of the 'number_integer' formatter.

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal