FieldFormatter.php

Same filename in this branch
  1. 11.x core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php
Same filename and directory in other branches
  1. 9 core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php
  2. 8.9.x core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php
  3. 10 core/lib/Drupal/Core/Field/Attribute/FieldFormatter.php
  4. 10 core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php

Namespace

Drupal\Core\Field\Attribute

File

core/lib/Drupal/Core/Field/Attribute/FieldFormatter.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Core\Field\Attribute;

use Drupal\Component\Plugin\Attribute\Plugin;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * Defines a FieldFormatter attribute for plugin discovery.
 *
 * Formatters handle the display of field values. They are typically
 * instantiated and invoked by an EntityDisplay object.
 *
 * Additional attribute keys for formatters can be defined in
 * hook_field_formatter_info_alter().
 *
 * @see \Drupal\Core\Field\FormatterPluginManager
 * @see \Drupal\Core\Field\FormatterInterface
 *
 * @ingroup field_formatter
 */
class FieldFormatter extends Plugin {
    
    /**
     * Constructs a FieldFormatter attribute.
     *
     * @param string $id
     *   The plugin ID.
     * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $label
     *   (optional) The human-readable name of the formatter type.
     * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
     *   (optional) A short description of the formatter type.
     * @param string[] $field_types
     *   (optional) An array of field types the formatter supports.
     * @param int|null $weight
     *   (optional) An integer to determine the weight of this formatter.
     *   Weight is relative to other formatters in the Field UI when selecting a
     *   formatter for a given field instance.
     * @param class-string|null $deriver
     *   (optional) The deriver class.
     */
    public function __construct(string $id, ?TranslatableMarkup $label = NULL, ?TranslatableMarkup $description = NULL, array $field_types = [], ?int $weight = NULL, ?string $deriver = NULL) {
    }

}

Classes

Title Deprecated Summary
FieldFormatter Defines a FieldFormatter attribute for plugin discovery.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.