By smustgrave on
Change record status:
Draft (View all draft change records)
Project:
Introduced in branch:
10.x
Introduced in version:
10.1.x
Issue links:
Description:
NodeViewBuilder no longer hardcodes the display of the langcode field allowing for formatter configurations to take affect. Now will be possible to achieve formats like:
- Display name with native names
- Add flag icons for languages
- Display source language
Wrapper was kept for backwards compatibility.
User interface slightly changes because field-language-display will be set to its default configuration to match previously hardcoded values.
Now developers will be able to provide new formatters in the following way:
namespace Drupal\custom_formatter\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldItemInterface;
use Drupal\Core\Field\Plugin\Field\FieldFormatter\LanguageFormatter as BaseFormatter;
/**
* Plugin implementation of the 'custom_formatter' formatter.
*
* @FieldFormatter(
* id = "language_custom_fomatter",
* label = @Translation("Language with flag"),
* field_types = {
* "language"
* }
* )
*/
class LanguageCustomFormatter extends BaseFormatter {
/**
* {@inheritdoc}
*/
protected function viewValue(FieldItemInterface $item) {
// Code to display value.
}
}Impacts:
Site builders, administrators, editors
Module developers
Themers