Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / lib / Drupal / Core / Field / Plugin / Field / FieldFormatter / IntegerFormatter.php
1 <?php
2
3 namespace Drupal\Core\Field\Plugin\Field\FieldFormatter;
4
5 /**
6  * Plugin implementation of the 'number_integer' formatter.
7  *
8  * The 'Default' formatter is different for integer fields on the one hand, and
9  * for decimal and float fields on the other hand, in order to be able to use
10  * different settings.
11  *
12  * @FieldFormatter(
13  *   id = "number_integer",
14  *   label = @Translation("Default"),
15  *   field_types = {
16  *     "integer"
17  *   }
18  * )
19  */
20 class IntegerFormatter extends NumericFormatterBase {
21
22   /**
23    * {@inheritdoc}
24    */
25   public static function defaultSettings() {
26     return [
27       'thousand_separator' => '',
28       'prefix_suffix' => TRUE,
29     ] + parent::defaultSettings();
30   }
31
32   /**
33    * {@inheritdoc}
34    */
35   protected function numberFormat($number) {
36     return number_format($number, 0, '', $this->getSetting('thousand_separator'));
37   }
38
39 }