You are here

public function PrintPage::getShareLink in Social simple 8

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

Class

PrintPage
The Printer button.

Namespace

Drupal\social_simple\SocialNetwork

Code

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