You are here

public function SharethisNode::render in ShareThis 8.2

Renders the field.

Parameters

\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.

Return value

string|\Drupal\Component\Render\MarkupInterface The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.

Overrides FieldPluginBase::render

File

src/Plugin/views/field/SharethisNode.php, line 66

Class

SharethisNode
Field handler to display the number of new comments.

Namespace

Drupal\sharethis\Plugin\views\field

Code

public function render(ResultRow $values) {
  $sharethis_manager = $this->sharethisManager;
  $node = $values->_entity;
  $m_title = $node
    ->getTitle();
  $m_path = $node
    ->toUrl()
    ->setAbsolute()
    ->toString();
  $data_options = $sharethis_manager
    ->getOptions();
  $st_js = $sharethis_manager
    ->sharethisIncludeJs();
  $content = $sharethis_manager
    ->renderSpans($data_options, $m_title, $m_path);
  return [
    '#theme' => 'sharethis_block',
    '#content' => $content,
    '#attached' => [
      'library' => [
        'sharethis/sharethispickerexternalbuttonsws',
        'sharethis/sharethispickerexternalbuttons',
        'sharethis/sharethis',
      ],
      'drupalSettings' => [
        'sharethis' => $st_js,
      ],
    ],
  ];
}