You are here

public function Linkedin::getShareLink in Social simple 8

Same name and namespace in other branches
  1. 2.0.x src/SocialNetwork/Linkedin.php \Drupal\social_simple\SocialNetwork\Linkedin::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/Linkedin.php, line 38

Class

Linkedin
The social network Linkedin.

Namespace

Drupal\social_simple\SocialNetwork

Code

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