class TextFormat

Same name in this branch
  1. 9 core/modules/filter/src/Element/TextFormat.php \Drupal\filter\Element\TextFormat
Same name in other branches
  1. 8.9.x core/modules/config_translation/src/FormElement/TextFormat.php \Drupal\config_translation\FormElement\TextFormat
  2. 8.9.x core/modules/filter/src/Element/TextFormat.php \Drupal\filter\Element\TextFormat
  3. 10 core/modules/config_translation/src/FormElement/TextFormat.php \Drupal\config_translation\FormElement\TextFormat
  4. 10 core/modules/filter/src/Element/TextFormat.php \Drupal\filter\Element\TextFormat
  5. 11.x core/modules/config_translation/src/FormElement/TextFormat.php \Drupal\config_translation\FormElement\TextFormat
  6. 11.x core/modules/filter/src/Element/TextFormat.php \Drupal\filter\Element\TextFormat

Defines the text_format element for the configuration translation interface.

Hierarchy

Expanded class hierarchy of TextFormat

4 string references to 'TextFormat'
ClaroPreRender::trustedCallbacks in core/themes/claro/src/ClaroPreRender.php
claro_element_info_alter in core/themes/claro/claro.theme
Implements hook_element_info_alter().
OliveroPreRender::trustedCallbacks in core/themes/olivero/src/OliveroPreRender.php
olivero_element_info_alter in core/themes/olivero/olivero.theme
Implements hook_element_info_alter().

File

core/modules/config_translation/src/FormElement/TextFormat.php, line 10

Namespace

Drupal\config_translation\FormElement
View 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

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
FormElementBase::$definition protected property The data definition of the element this form element is for.
FormElementBase::$element protected property The schema element this form is for.
FormElementBase::create public static function Overrides ElementInterface::create
FormElementBase::getTranslationBuild public function Overrides ElementInterface::getTranslationBuild
FormElementBase::setConfig public function Overrides ElementInterface::setConfig 1
FormElementBase::__construct public function Constructs a FormElementBase.
StringTranslationTrait::$stringTranslation protected property The string translation service. 3
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
TextFormat::getSourceElement public function Overrides FormElementBase::getSourceElement
TextFormat::getTranslationElement public function Overrides FormElementBase::getTranslationElement

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.