You are here

class Text in Drupal 10

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

Views area text handler.

Plugin annotation

@ViewsArea("text");

Hierarchy

  • class \Drupal\views\Plugin\views\area\AreaPluginBase extends \Drupal\views\Plugin\views\HandlerBase

Expanded class hierarchy of Text

Related topics

20 string references to 'Text'
contact_entity_extra_field_info in core/modules/contact/contact.module
Implements hook_entity_extra_field_info().
core.data_types.schema.yml in core/config/schema/core.data_types.schema.yml
core/config/schema/core.data_types.schema.yml
drupal6.php in core/modules/migrate_drupal/tests/fixtures/drupal6.php
A database agnostic dump for testing purposes.
FormTestClickedButtonForm::buildForm in core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php
Form constructor.
hook_system_breadcrumb_alter in core/lib/Drupal/Core/Menu/menu.api.php
Perform alterations to the breadcrumb built by the BreadcrumbManager.

... 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 [];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AreaPluginBase::$areaType public property The type of this area handler, i.e. 'header', 'footer', or 'empty'.
AreaPluginBase::adminSummary public function
AreaPluginBase::init public function Overrides Drupal\views\Plugin\views\HandlerBase::init(). 1
AreaPluginBase::isEmpty public function Does that area have nothing to show. 1
AreaPluginBase::preRender public function Performs any operations needed before full rendering. 1
AreaPluginBase::usesGroupBy public function
Text::buildOptionsForm public function Overrides TokenizeAreaPluginBase::buildOptionsForm
Text::defineOptions protected function Overrides TokenizeAreaPluginBase::defineOptions
Text::preQuery public function
Text::render public function Render the area. Overrides AreaPluginBase::render
TokenizeAreaPluginBase::tokenForm public function Adds tokenization form elements.
TokenizeAreaPluginBase::tokenizeValue public function Replaces value with special views tokens and global tokens.