class TextFormat in Drupal 8
Same name in this branch
- 8 core/modules/filter/src/Element/TextFormat.php \Drupal\filter\Element\TextFormat
- 8 core/modules/config_translation/src/FormElement/TextFormat.php \Drupal\config_translation\FormElement\TextFormat
Same name and namespace in other branches
- 9 core/modules/config_translation/src/FormElement/TextFormat.php \Drupal\config_translation\FormElement\TextFormat
Defines the text_format element for the configuration translation interface.
Hierarchy
- class \Drupal\config_translation\FormElement\FormElementBase implements ElementInterface uses StringTranslationTrait
- class \Drupal\config_translation\FormElement\TextFormat
Expanded class hierarchy of TextFormat
File
- core/
modules/ config_translation/ src/ FormElement/ TextFormat.php, line 10
Namespace
Drupal\config_translation\FormElementView source
class TextFormat extends FormElementBase {
/**
* {@inheritdoc}
*/
public function getSourceElement(LanguageInterface $source_language, $source_config) {
// Instead of the formatted output show a disabled textarea. This allows for
// easier side-by-side comparison, especially with formats with text
// editors.
return $this
->getTranslationElement($source_language, $source_config, $source_config) + [
'#value' => $source_config['value'],
'#disabled' => TRUE,
'#allow_focus' => TRUE,
];
}
/**
* {@inheritdoc}
*/
public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) {
return [
'#type' => 'text_format',
// Override the #default_value property from the parent class.
'#default_value' => $translation_config['value'],
'#format' => $translation_config['format'],
// @see \Drupal\config_translation\Element\FormElementBase::getTranslationElement()
'#allowed_formats' => [
$source_config['format'],
],
] + parent::getTranslationElement($translation_language, $source_config, $translation_config);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FormElementBase:: |
protected | property | The data definition of the element this form element is for. | |
FormElementBase:: |
protected | property | The schema element this form is for. | |
FormElementBase:: |
public static | function |
Creates a form element instance from a schema definition. Overrides ElementInterface:: |
|
FormElementBase:: |
public | function |
Builds a render array containing the source and translation form elements. Overrides ElementInterface:: |
|
FormElementBase:: |
public | function |
Sets configuration based on a nested form value array. Overrides ElementInterface:: |
1 |
FormElementBase:: |
public | function | Constructs a FormElementBase. | |
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. | |
TextFormat:: |
public | function |
Returns the source element for a given configuration definition. Overrides FormElementBase:: |
|
TextFormat:: |
public | function |
Returns the translation form element for a given configuration definition. Overrides FormElementBase:: |