/** * {@inheritdoc} */ public function build() { if ($this->sharethisSettings->get('location') === 'block') { $st_js = $this->sharethisManager->sharethisIncludeJs(); $markup = $this->sharethisManager->blockContents(); return ['#theme' => 'sharethis_block', '#content' => $markup, '#attached' => array('library' => array('sharethis/sharethispickerexternalbuttonsws', 'sharethis/sharethispickerexternalbuttons', 'sharethis/sharethis'), 'drupalSettings' => array('sharethis' => $st_js))]; } }
/** * {@inheritdoc} */ public function build() { if ($this->sharethisSettings->get('location') === 'block') { $st_js = $this->sharethisManager->sharethisIncludeJs(); if ($this->configuration['sharethis_path'] == 'external') { $mpath = $this->configuration['sharethis_path_external']; } else { $current_path = \Drupal::url('<current>'); $path = $this->configuration['sharethis_path'] == 'global' ? '<front>' : $current_path; global $base_url; $path_obj = Url::fromUri($base_url . '/' . $path, array('absolute' => TRUE)); $mpath = $path_obj->toString(); } $request = \Drupal::request(); $route_match = \Drupal::routeMatch(); $title = \Drupal::service('title_resolver')->getTitle($request, $route_match->getRouteObject()); $title = is_object($title) ? $title->getUntranslatedString() : $title; $mtitle = $this->configuration['sharethis_path'] == 'current' ? $title : \Drupal::config('system.site')->get('name'); $markup = $this->sharethisManager->widgetContents(array('m_path' => $mpath, 'm_title' => $mtitle)); return ['#theme' => 'sharethis_block', '#content' => $markup, '#attached' => array('library' => array('sharethis/sharethispickerexternalbuttonsws', 'sharethis/sharethispickerexternalbuttons', 'sharethis/sharethis'), 'drupalSettings' => array('sharethis' => $st_js))]; } }