class FieldFormatter

Defines a FieldFormatter annotation object.

Formatters handle the display of field values. Formatter hooks are typically called by the Field Attach API field_attach_prepare_view() and field_attach_view() functions.

Additional annotation keys for formatters can be defined in hook_field_formatter_info_alter().

Hierarchy

Expanded class hierarchy of FieldFormatter

See also

\Drupal\field\Plugin\Type\Formatter\FormatterPluginManager

\Drupal\field\Plugin\Type\Formatter\FormatterInterface

35 files declare their use of FieldFormatter
DatetimeDefaultFormatter.php in drupal/core/modules/datetime/lib/Drupal/datetime/Plugin/field/formatter/DatetimeDefaultFormatter.php
Contains \Drupal\datetime\Plugin\field\formatter\DateTimeDefaultFormatter.
DatetimePlainFormatter.php in drupal/core/modules/datetime/lib/Drupal/datetime/Plugin/field/formatter/DatetimePlainFormatter.php
Contains \Drupal\datetime\Plugin\field\formatter\DateTimePlainFormatter.
DefaultNumberFormatter.php in drupal/core/modules/number/lib/Drupal/number/Plugin/field/formatter/DefaultNumberFormatter.php
Contains \Drupal\number\Plugin\field\formatter\DefaultNumberFormatter.
EntityReferenceEntityFormatter.php in drupal/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceEntityFormatter.php
Contains \Drupal\entity_reference\Plugin\field\formatter\EntityReferenceEntityFormatter.
EntityReferenceFormatterBase.php in drupal/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceFormatterBase.php
Contains \Drupal\entity_reference\Plugin\field\formatter\EntityReferenceFormatterBase.

... See full list

32 classes are annotated with FieldFormatter
DateTimeDefaultFormatter in drupal/core/modules/datetime/lib/Drupal/datetime/Plugin/field/formatter/DatetimeDefaultFormatter.php
Plugin implementation of the 'datetime_default' formatter.
DateTimePlainFormatter in drupal/core/modules/datetime/lib/Drupal/datetime/Plugin/field/formatter/DatetimePlainFormatter.php
Plugin implementation of the 'datetime_plain' formatter.
EntityReferenceEntityFormatter in drupal/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceEntityFormatter.php
Plugin implementation of the 'entity reference rendered entity' formatter.
EntityReferenceIdFormatter in drupal/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceIdFormatter.php
Plugin implementation of the 'entity reference ID' formatter.
EntityReferenceLabelFormatter in drupal/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceLabelFormatter.php
Plugin implementation of the 'entity reference label' formatter.

... See full list

File

drupal/core/modules/field/lib/Drupal/field/Annotation/FieldFormatter.php, line 27
Contains \Drupal\field\Annotation\FieldFormatter.

Namespace

Drupal\field\Annotation
View source
class FieldFormatter extends Plugin {

  /**
   * The plugin ID.
   *
   * @var string
   */
  public $id;

  /**
   * The human-readable name of the formatter type.
   *
   * @ingroup plugin_translatable
   *
   * @var \Drupal\Core\Annotation\Translation
   */
  public $label;

  /**
   * A short description of the formatter type.
   *
   * @ingroup plugin_translatable
   *
   * @var \Drupal\Core\Annotation\Translation
   */
  public $description;

  /**
   * The name of the module providing the formatter.
   *
   * @var string
   */
  public $module;

  /**
   * The name of the field formatter class.
   *
   * This is not provided manually, it will be added by the discovery mechanism.
   *
   * @var string
   */
  public $class;

  /**
   * An array of field types the formatter supports.
   *
   * @var array
   */
  public $field_types = array();

  /**
   * An array whose keys are the names of the settings available to the
   * formatter type, and whose values are the default values for those settings.
   *
   * @var array
   */
  public $settings = array();

}

Members

Namesort descending Modifiers Type Description Overrides
FieldFormatter::$class public property The name of the field formatter class.
FieldFormatter::$description public property A short description of the formatter type.
FieldFormatter::$field_types public property An array of field types the formatter supports.
FieldFormatter::$id public property The plugin ID.
FieldFormatter::$label public property The human-readable name of the formatter type.
FieldFormatter::$module public property The name of the module providing the formatter.
FieldFormatter::$settings public property An array whose keys are the names of the settings available to the formatter type, and whose values are the default values for those settings.
Plugin::$definition protected property The plugin definiton read from the class annotation.
Plugin::get public function Implements Drupal\Core\Annotation\AnnotationInterface::get(). Overrides AnnotationInterface::get
Plugin::parse protected function Parses an annotation into its definition.
Plugin::__construct public function Constructs a Plugin object.