public function Mail::getShareLink in Social simple 8
Same name and namespace in other branches
- 2.0.x src/SocialNetwork/Mail.php \Drupal\social_simple\SocialNetwork\Mail::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/ Mail.php, line 51
Class
- The Mail button.
Namespace
Drupal\social_simple\SocialNetworkCode
public function getShareLink($share_url, $title = '', EntityInterface $entity = NULL, array $additional_options = []) {
$options = [
'query' => [
'body' => PHP_EOL . $title . PHP_EOL . $share_url,
'subject' => $title,
],
'absolute' => TRUE,
'external' => TRUE,
];
if ($additional_options) {
foreach ($additional_options as $id => $value) {
$options['query'][$id] = $value;
}
}
if ($entity && $this
->checkForwardIntegration($entity)) {
$url = Url::fromRoute('forward.form', [
'entity_type' => $entity
->getEntityTypeId(),
'entity' => $entity
->id(),
]);
}
else {
$url = Url::fromUri(self::MAIL, $options);
}
$link = [
'url' => $url,
'title' => [
'#markup' => '<i class="fa fa-envelope"></i><span class="visually-hidden">' . $this
->getLabel() . '</span>',
],
'attributes' => $this
->getLinkAttributes($this
->getLabel()),
];
return $link;
}