class ExampleFormattedField in Extra Field 8.2
Same name and namespace in other branches
- 8 modules/extra_field_example/src/Plugin/ExtraField/Display/ExampleFormattedField.php \Drupal\extra_field_example\Plugin\ExtraField\Display\ExampleFormattedField
Example Extra field with formatted output.
Plugin annotation
@ExtraFieldDisplay(
id = "formatted_field",
label = @Translation("Data formatted as field with label"),
description = @Translation("An extra field to display multiple text items."),
bundles = {
"node.article",
}
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\extra_field\Plugin\ExtraFieldDisplayBase implements ExtraFieldDisplayInterface
- class \Drupal\extra_field\Plugin\ExtraFieldDisplayFormattedBase implements ExtraFieldDisplayFormattedInterface
- class \Drupal\extra_field_example\Plugin\ExtraField\Display\ExampleFormattedField uses StringTranslationTrait
- class \Drupal\extra_field\Plugin\ExtraFieldDisplayFormattedBase implements ExtraFieldDisplayFormattedInterface
- class \Drupal\extra_field\Plugin\ExtraFieldDisplayBase implements ExtraFieldDisplayInterface
Expanded class hierarchy of ExampleFormattedField
File
- modules/
extra_field_example/ src/ Plugin/ ExtraField/ Display/ ExampleFormattedField.php, line 21
Namespace
Drupal\extra_field_example\Plugin\ExtraField\DisplayView source
class ExampleFormattedField extends ExtraFieldDisplayFormattedBase {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function getLabel() {
return $this
->t('Three items');
}
/**
* {@inheritdoc}
*/
public function getLabelDisplay() {
return 'above';
}
/**
* {@inheritdoc}
*/
public function viewElements(ContentEntityInterface $entity) {
return [
[
'#markup' => 'One',
],
[
'#markup' => 'Two',
],
[
'#markup' => 'Three',
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ExampleFormattedField:: |
public | function |
The label of the field. Overrides ExtraFieldDisplayFormattedBase:: |
|
ExampleFormattedField:: |
public | function |
How to display the field label will be displayed. Overrides ExtraFieldDisplayFormattedBase:: |
|
ExampleFormattedField:: |
public | function |
Returns the renderable array of the field item(s). Overrides ExtraFieldDisplayFormattedInterface:: |
|
ExtraFieldDisplayBase:: |
protected | property | The field's parent entity. | |
ExtraFieldDisplayBase:: |
protected | property | The entity view display. | |
ExtraFieldDisplayBase:: |
protected | property | The view mode the entity is rendered in. | |
ExtraFieldDisplayBase:: |
public | function |
Returns the field's parent entity. Overrides ExtraFieldDisplayInterface:: |
|
ExtraFieldDisplayBase:: |
public | function |
Returns the entity view display object of the field's host entity. Overrides ExtraFieldDisplayInterface:: |
|
ExtraFieldDisplayBase:: |
public | function |
Returns the entity view mode object of the field's host entity. Overrides ExtraFieldDisplayInterface:: |
|
ExtraFieldDisplayBase:: |
public | function |
Stores the field's parent entity. Overrides ExtraFieldDisplayInterface:: |
|
ExtraFieldDisplayBase:: |
public | function |
Stores the entity view display. Overrides ExtraFieldDisplayInterface:: |
|
ExtraFieldDisplayBase:: |
public | function |
Stores the entity view mode. Overrides ExtraFieldDisplayInterface:: |
|
ExtraFieldDisplayFormattedBase:: |
protected | property | Flag to indicate that the extra field has no content. | |
ExtraFieldDisplayFormattedBase:: |
protected | property | The langcode of the field values. | |
ExtraFieldDisplayFormattedBase:: |
protected | property | The language manager. | |
ExtraFieldDisplayFormattedBase:: |
public | function |
The machine name of the field. Overrides ExtraFieldDisplayFormattedInterface:: |
1 |
ExtraFieldDisplayFormattedBase:: |
public | function |
The type of field. Overrides ExtraFieldDisplayFormattedInterface:: |
1 |
ExtraFieldDisplayFormattedBase:: |
public | function |
Gets the langcode of the field values. Overrides ExtraFieldDisplayFormattedInterface:: |
1 |
ExtraFieldDisplayFormattedBase:: |
public | function |
Check if the extra field has data. Overrides ExtraFieldDisplayFormattedInterface:: |
|
ExtraFieldDisplayFormattedBase:: |
public | function |
The field is translatable. Overrides ExtraFieldDisplayFormattedInterface:: |
1 |
ExtraFieldDisplayFormattedBase:: |
public | function | Set the language code. | |
ExtraFieldDisplayFormattedBase:: |
public | function |
Builds a renderable array for the field. Overrides ExtraFieldDisplayInterface:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |