3 namespace Drupal\views\Plugin\views\field;
5 use Drupal\views\Plugin\views\display\DisplayPluginBase;
6 use Drupal\views\ResultRow;
7 use Drupal\views\ViewExecutable;
10 * A handler to run a field through check_markup, using a companion
13 * - format: (REQUIRED) Either a string format id to use for this field or an
14 * array('field' => {$field}) where $field is the field in this table
15 * used to control the format such as the 'format' field in the node,
16 * which goes with the 'body' field.
18 * @ingroup views_field_handlers
20 * @ViewsField("markup")
22 class Markup extends FieldPluginBase {
27 public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
28 parent::init($view, $display, $options);
30 $this->format = $this->definition['format'];
32 $this->additional_fields = [];
33 if (is_array($this->format)) {
34 $this->additional_fields['format'] = $this->format;
41 public function render(ResultRow $values) {
42 $value = $this->getValue($values);
43 if (is_array($this->format)) {
44 $format = $this->getValue($values, 'format');
47 $format = $this->format;
50 $value = str_replace('<!--break-->', '', $value);
51 return check_markup($value, $format);
58 public function elementType($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) {
63 if (isset($this->definition['element type'])) {
64 return $this->definition['element type'];