public function Facebook::getShareLink in Social simple 2.0.x
Same name and namespace in other branches
- 8 src/SocialNetwork/Facebook.php \Drupal\social_simple\SocialNetwork\Facebook::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/ Facebook.php, line 38
Class
- The social network Facebook.
Namespace
Drupal\social_simple\SocialNetworkCode
public function getShareLink($share_url, $title = '', EntityInterface $entity = NULL, array $additional_options = []) {
$options = [
'query' => [
'u' => $share_url,
],
'absolute' => TRUE,
'external' => TRUE,
];
if ($additional_options) {
foreach ($additional_options as $id => $value) {
$options['query'][$id] = $value;
}
}
$url = Url::fromUri(self::FACEBOOK_URL, $options);
$link = [
'url' => $url,
'title' => [
'#markup' => '<i class="fa fa-facebook"></i><span class="visually-hidden">' . $this
->getLabel() . '</span>',
],
'attributes' => $this
->getLinkAttributes($this
->getLabel()),
];
return $link;
}