FieldFormatter.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace Drupal\Core\Field\Annotation;
  3. use Drupal\Component\Annotation\Plugin;
  4. /**
  5. * Defines a FieldFormatter annotation object.
  6. *
  7. * Formatters handle the display of field values. They are typically
  8. * instantiated and invoked by an EntityDisplay object.
  9. *
  10. * Additional annotation keys for formatters can be defined in
  11. * hook_field_formatter_info_alter().
  12. *
  13. * @Annotation
  14. *
  15. * @see \Drupal\Core\Field\FormatterPluginManager
  16. * @see \Drupal\Core\Field\FormatterInterface
  17. *
  18. * @ingroup field_formatter
  19. */
  20. class FieldFormatter extends Plugin {
  21. /**
  22. * The plugin ID.
  23. *
  24. * @var string
  25. */
  26. public $id;
  27. /**
  28. * The human-readable name of the formatter type.
  29. *
  30. * @ingroup plugin_translatable
  31. *
  32. * @var \Drupal\Core\Annotation\Translation
  33. */
  34. public $label;
  35. /**
  36. * A short description of the formatter type.
  37. *
  38. * @ingroup plugin_translatable
  39. *
  40. * @var \Drupal\Core\Annotation\Translation
  41. */
  42. public $description;
  43. /**
  44. * The name of the field formatter class.
  45. *
  46. * This is not provided manually, it will be added by the discovery mechanism.
  47. *
  48. * @var string
  49. */
  50. public $class;
  51. /**
  52. * An array of field types the formatter supports.
  53. *
  54. * @var array
  55. */
  56. public $field_types = [];
  57. /**
  58. * An integer to determine the weight of this formatter relative to other
  59. * formatter in the Field UI when selecting a formatter for a given field
  60. * instance.
  61. *
  62. * @var int optional
  63. */
  64. public $weight = NULL;
  65. }