FormatterInterface
interface FormatterInterface implements PluginSettingsInterface (View source)
Interface definition for field formatter plugins.
Methods
Gets the definition of the plugin implementation.
Sets the value of a third-party setting.
Gets the value of a third-party setting.
Gets all third-party settings of a given module.
Unsets a third-party setting.
Gets the list of third parties that store information.
Defines the default settings for this plugin.
Returns the array of settings, including defaults for missing settings.
Returns the value of a setting, or its default value if absent.
Sets the value of a setting for the plugin.
Informs the plugin that some configuration it depends on will be deleted.
Returns a form to configure settings for the formatter.
Returns a short summary for the current formatter settings.
Allows formatters to load information for field values being displayed.
Builds a renderable array for a fully themed field.
Builds a renderable array for a field value.
Returns if the formatter can be used for the provided field.
Details
string
getPluginId()
Gets the plugin_id of the plugin instance.
array
getPluginDefinition()
Gets the definition of the plugin implementation.
$this
setThirdPartySetting(string $module, string $key, mixed $value)
Sets the value of a third-party setting.
mixed
getThirdPartySetting(string $module, string $key, mixed $default = NULL)
Gets the value of a third-party setting.
array
getThirdPartySettings(string $module)
Gets all third-party settings of a given module.
mixed
unsetThirdPartySetting(string $module, string $key)
Unsets a third-party setting.
array
getThirdPartyProviders()
Gets the list of third parties that store information.
static array
defaultSettings()
Defines the default settings for this plugin.
array
getSettings()
Returns the array of settings, including defaults for missing settings.
mixed
getSetting(string $key)
Returns the value of a setting, or its default value if absent.
$this
setSettings(array $settings)
Sets the settings for the plugin.
$this
setSetting(string $key, mixed $value)
Sets the value of a setting for the plugin.
bool
onDependencyRemoval(array $dependencies)
Informs the plugin that some configuration it depends on will be deleted.
This method allows plugins to keep their configuration up-to-date when a dependency calculated with ::calculateDependencies() is removed. For example, an entity view display contains a formatter having a setting pointing to an arbitrary config entity. When that config entity is deleted, this method is called by the view display to react to the dependency removal by updating its configuration.
This method must return TRUE if the removal event updated the plugin configuration or FALSE otherwise.
array
settingsForm(array $form, FormStateInterface $form_state)
Returns a form to configure settings for the formatter.
Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.
string[]
settingsSummary()
Returns a short summary for the current formatter settings.
If an empty result is returned, a UI can still be provided to display a settings form in case the formatter has configurable settings.
prepareView(array $entities_items)
Allows formatters to load information for field values being displayed.
This should be used when a formatter needs to load additional information from the database in order to render a field, for example a reference field that displays properties of the referenced entities such as name or type.
This method operates on multiple entities. The $entities_items parameter is an array keyed by entity ID. For performance reasons, information for all involved entities should be loaded in a single query where possible.
Changes or additions to field values are done by directly altering the items.
array
view(FieldItemListInterface $items, string $langcode = NULL)
Builds a renderable array for a fully themed field.
array
viewElements(FieldItemListInterface $items, string $langcode)
Builds a renderable array for a field value.
static bool
isApplicable(FieldDefinitionInterface $field_definition)
Returns if the formatter can be used for the provided field.