Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 29 |
Text | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
56 | |
0.00% |
0 / 29 |
defineOptions | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 9 |
|||
buildOptionsForm | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 10 |
|||
render | |
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 10 |
<?php | |
/** | |
* @file | |
* Contains \Drupal\views\Plugin\views\area\Text. | |
*/ | |
namespace Drupal\views\Plugin\views\area; | |
use Drupal\Core\Form\FormStateInterface; | |
/** | |
* Views area text handler. | |
* | |
* @ingroup views_area_handlers | |
* | |
* @ViewsArea("text") | |
*/ | |
class Text extends TokenizeAreaPluginBase { | |
/** | |
* {@inheritdoc} | |
*/ | |
protected function defineOptions() { | |
$options = parent::defineOptions(); | |
$options['content'] = array( | |
'contains' => array( | |
'value' => array('default' => ''), | |
'format' => array('default' => NULL), | |
), | |
); | |
return $options; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function buildOptionsForm(&$form, FormStateInterface $form_state) { | |
parent::buildOptionsForm($form, $form_state); | |
$form['content'] = array( | |
'#title' => $this->t('Content'), | |
'#type' => 'text_format', | |
'#default_value' => $this->options['content']['value'], | |
'#rows' => 6, | |
'#format' => isset($this->options['content']['format']) ? $this->options['content']['format'] : filter_default_format(), | |
'#editor' => FALSE, | |
); | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function render($empty = FALSE) { | |
$format = isset($this->options['content']['format']) ? $this->options['content']['format'] : filter_default_format(); | |
if (!$empty || !empty($this->options['empty'])) { | |
return array( | |
'#type' => 'processed_text', | |
'#text' => $this->tokenizeValue($this->options['content']['value']), | |
'#format' => $format, | |
); | |
} | |
return array(); | |
} | |
} |