You are here

public function SharethisManager::blockContents in ShareThis 8.2

Custom html block.

Return value

array Return array renderable by renderSpans().

Overrides SharethisManagerInterface::blockContents

File

src/SharethisManager.php, line 108

Class

SharethisManager
Defines an SharethisManager service.

Namespace

Drupal\sharethis

Code

public function blockContents() {
  $sharethis_config = $this->configFactory
    ->get('sharethis.settings');
  $config = $this->configFactory
    ->get('system.site');
  if ($sharethis_config
    ->get('location') == 'block') {

    // First Get all of the options for sharethis widget from database.
    $data_options = $this
      ->getOptions();
    $request = $this->requestStack
      ->getCurrentRequest();

    // Get an absolute path to the current page.
    $m_path = $request
      ->getUri();
    $mtitle = $this->titleResolver
      ->getTitle($request, $this->routeMatch
      ->getRouteObject());
    if (!empty($mtitle) && is_object($mtitle)) {
      $m_title = $mtitle
        ->getUntranslatedString();
    }
    elseif (!empty($mtitle) && is_string($mtitle)) {
      $m_title = $mtitle;
    }
    else {
      $m_title = $config
        ->get('name');
    }
    return $this
      ->renderSpans($data_options, $m_title, $m_path);
  }
}