class GooglePlus in Social simple 8
Same name and namespace in other branches
- 2.0.x src/SocialNetwork/GooglePlus.php \Drupal\social_simple\SocialNetwork\GooglePlus
The social network Google+.
Hierarchy
- class \Drupal\social_simple\SocialNetwork\GooglePlus implements SocialNetworkInterface uses StringTranslationTrait
Expanded class hierarchy of GooglePlus
1 string reference to 'GooglePlus'
1 service uses GooglePlus
File
- src/
SocialNetwork/ GooglePlus.php, line 12
Namespace
Drupal\social_simple\SocialNetworkView source
class GooglePlus implements SocialNetworkInterface {
use StringTranslationTrait;
/**
* The social network base share link.
*/
const GOOGLEPLUS_URL = 'https://plus.google.com/share';
/**
* {@inheritdoc}
*/
public function getId() {
return 'googleplus';
}
/**
* {@inheritdoc}
*/
public function getLabel() {
return $this
->t('Google+');
}
/**
* {@inheritdoc}
*/
public function getShareLink($share_url, $title = '', EntityInterface $entity = NULL, array $additional_options = []) {
$options = [
'query' => [
'url' => $share_url,
],
'absolute' => TRUE,
'external' => TRUE,
];
if ($additional_options) {
foreach ($additional_options as $id => $value) {
$options['query'][$id] = $value;
}
}
$url = Url::fromUri(self::GOOGLEPLUS_URL, $options);
$link = [
'url' => $url,
'title' => [
'#markup' => '<i class="fa fa-google-plus"></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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
GooglePlus:: |
public | function |
Get the network id. Overrides SocialNetworkInterface:: |
|
GooglePlus:: |
public | function |
Get the network name. Overrides SocialNetworkInterface:: |
|
GooglePlus:: |
public | function |
Get common attributes for the share link. Overrides SocialNetworkInterface:: |
|
GooglePlus:: |
public | function |
Checks whether the given transition is allowed. Overrides SocialNetworkInterface:: |
|
GooglePlus:: |
constant | The social network base share link. | ||
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |