class Text

Same name and namespace in other branches
  1. 11.x core/modules/views/src/Plugin/views/area/Text.php \Drupal\views\Plugin\views\area\Text

Views area text handler.

Plugin annotation

@ViewsArea("text");

Hierarchy

Expanded class hierarchy of Text

Related topics

320 string references to 'Text'
block_content.schema.yml in core/modules/block_content/config/schema/block_content.schema.yml
core/modules/block_content/config/schema/block_content.schema.yml
ckeditor.schema.yml in core/modules/ckeditor/config/schema/ckeditor.schema.yml
core/modules/ckeditor/config/schema/ckeditor.schema.yml
claro_preprocess_input in core/themes/claro/claro.theme
Implements template_preprocess_HOOK() for input.
comment.schema.yml in core/modules/comment/config/schema/comment.schema.yml
core/modules/comment/config/schema/comment.schema.yml
CommentEntityTranslationTest::providerSource in core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d7/CommentEntityTranslationTest.php

... See full list

File

core/modules/views/src/Plugin/views/area/Text.php, line 14

Namespace

Drupal\views\Plugin\views\area
View source
class Text extends TokenizeAreaPluginBase {
  
  /**
   * {@inheritdoc}
   */
  protected function defineOptions() {
    $options = parent::defineOptions();
    $options['content'] = [
      'contains' => [
        'value' => [
          'default' => '',
        ],
        'format' => [
          'default' => NULL,
        ],
      ],
    ];
    return $options;
  }
  
  /**
   * {@inheritdoc}
   */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);
    $form['content'] = [
      '#title' => $this->t('Content'),
      '#type' => 'text_format',
      '#default_value' => $this->options['content']['value'],
      '#rows' => 6,
      '#format' => $this->options['content']['format'] ?? filter_default_format(),
      '#editor' => FALSE,
    ];
  }
  
  /**
   * {@inheritdoc}
   */
  public function preQuery() {
    $content = $this->options['content']['value'];
    // Check for tokens that require a total row count.
    if (strpos($content, '[view:page-count]') !== FALSE || strpos($content, '[view:total-rows]') !== FALSE) {
      $this->view->get_total_rows = TRUE;
    }
  }
  
  /**
   * {@inheritdoc}
   */
  public function render($empty = FALSE) {
    $format = $this->options['content']['format'] ?? filter_default_format();
    if (!$empty || !empty($this->options['empty'])) {
      return [
        '#type' => 'processed_text',
        '#text' => $this->tokenizeValue($this->options['content']['value']),
        '#format' => $format,
      ];
    }
    return [];
  }

}

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