
| Current Path : /var/www/html/rocksensor1/web/core/modules/views/src/Plugin/views/area/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/rocksensor1/web/core/modules/views/src/Plugin/views/area/Text.php |
<?php
namespace Drupal\views\Plugin\views\area;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Attribute\ViewsArea;
/**
* Views area text handler.
*
* @ingroup views_area_handlers
*/
#[ViewsArea("text")]
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 (str_contains($content, '[view:page-count]') || str_contains($content, '[view:total-rows]')) {
$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 [];
}
}