You are here

public function GooglePlus::getShareLink in Social simple 8

Same name and namespace in other branches
  1. 2.0.x src/SocialNetwork/GooglePlus.php \Drupal\social_simple\SocialNetwork\GooglePlus::getShareLink()

Checks whether the given transition is allowed.

Parameters

string $share_url: The url to share.

string $title: The page's title to share.

\Drupal\Core\Entity\EntityInterface $entity: The parent entity.

array $additional_options: Additional options to pass as que query parameter to the social link.

Return value

array the renderable array of the social share link.

Overrides SocialNetworkInterface::getShareLink

File

src/SocialNetwork/GooglePlus.php, line 38

Class

GooglePlus
The social network Google+.

Namespace

Drupal\social_simple\SocialNetwork

Code

public function getShareLink($share_url, $title = '', EntityInterface $entity = NULL, array $additional_options = []) {
  $options = [
    'query' => [
      'url' => $share_url,
    ],
    'absolute' => TRUE,
    'external' => TRUE,
  ];
  if ($additional_options) {
    foreach ($additional_options as $id => $value) {
      $options['query'][$id] = $value;
    }
  }
  $url = Url::fromUri(self::GOOGLEPLUS_URL, $options);
  $link = [
    'url' => $url,
    'title' => [
      '#markup' => '<i class="fa fa-google-plus"></i><span class="visually-hidden">' . $this
        ->getLabel() . '</span>',
    ],
    'attributes' => $this
      ->getLinkAttributes($this
      ->getLabel()),
  ];
  return $link;
}