NodeHtmlTitle.php in HTML Title 8
File
src/Plugin/views/field/NodeHtmlTitle.php
View source
<?php
namespace Drupal\html_title\Plugin\views\field;
use Drupal\html_title\HtmlTitleFilter;
use Drupal\views\Plugin\views\field\EntityField;
use Symfony\Component\DependencyInjection\ContainerInterface;
class NodeHtmlTitle extends EntityField {
protected $htmlTitleFilter;
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
$instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
$instance
->setHtmlTitleFilter($container
->get('html_title.filter'));
return $instance;
}
public function setHtmlTitleFilter(HtmlTitleFilter $html_title_filter) {
$this->htmlTitleFilter = $html_title_filter;
return $this;
}
public function renderText($alter) {
if ($this->options['settings']['link_to_entity'] === TRUE) {
$alter['rendered']['#title']['#context']['value'] = $this->htmlTitleFilter
->decodeToMarkup($alter['rendered']['#title']['#context']['value']);
$this->last_render = $this->renderer
->render($alter['rendered']);
}
else {
$rendered = $this->renderer
->render($alter['rendered']);
$this->last_render = $this->htmlTitleFilter
->decodeToMarkup($rendered);
}
return parent::renderText($alter);
}
}