You are here

class Linkedin in Social simple 2.0.x

Same name and namespace in other branches
  1. 8 src/SocialNetwork/Linkedin.php \Drupal\social_simple\SocialNetwork\Linkedin

The social network Linkedin.

Hierarchy

Expanded class hierarchy of Linkedin

1 string reference to 'Linkedin'
social_simple.services.yml in ./social_simple.services.yml
social_simple.services.yml
1 service uses Linkedin
social_simple.linkedin in ./social_simple.services.yml
Drupal\social_simple\SocialNetwork\Linkedin

File

src/SocialNetwork/Linkedin.php, line 12

Namespace

Drupal\social_simple\SocialNetwork
View source
class Linkedin implements SocialNetworkInterface {
  use StringTranslationTrait;

  /**
   * The social network base share link.
   */
  const LINKEDIN_URL = 'https://www.linkedin.com/shareArticle';

  /**
   * {@inheritdoc}
   */
  public function getId() {
    return 'linkedin';
  }

  /**
   * {@inheritdoc}
   */
  public function getLabel() {
    return $this
      ->t('Linked in');
  }

  /**
   * {@inheritdoc}
   */
  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;
  }

  /**
   * {@inheritdoc}
   */
  public function getLinkAttributes($network_name) {
    $attributes = [
      'data-popup-width' => 600,
      'data-popup-height' => 300,
      'data-toggle' => 'tooltip',
      'data-placement' => 'top',
      'title' => $network_name,
    ];
    return $attributes;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Linkedin::getId public function Get the network id. Overrides SocialNetworkInterface::getId
Linkedin::getLabel public function Get the network name. Overrides SocialNetworkInterface::getLabel
Linkedin::getLinkAttributes public function Get common attributes for the share link. Overrides SocialNetworkInterface::getLinkAttributes
Linkedin::getShareLink public function Checks whether the given transition is allowed. Overrides SocialNetworkInterface::getShareLink
Linkedin::LINKEDIN_URL constant The social network base share link.
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.