Text.php in Drupal 10
File
core/modules/views/src/Plugin/views/area/Text.php
View source
<?php
namespace Drupal\views\Plugin\views\area;
use Drupal\Core\Form\FormStateInterface;
class Text extends TokenizeAreaPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
$options['content'] = [
'contains' => [
'value' => [
'default' => '',
],
'format' => [
'default' => NULL,
],
],
];
return $options;
}
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,
];
}
public function preQuery() {
$content = $this->options['content']['value'];
if (strpos($content, '[view:page-count]') !== FALSE || strpos($content, '[view:total-rows]') !== FALSE) {
$this->view->get_total_rows = TRUE;
}
}
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 [];
}
}
Classes
Name |
Description |
Text |
Views area text handler. |