class Facebook in Social simple 2.0.x
Same name and namespace in other branches
- 8 src/SocialNetwork/Facebook.php \Drupal\social_simple\SocialNetwork\Facebook
The social network Facebook.
Hierarchy
- class \Drupal\social_simple\SocialNetwork\Facebook implements SocialNetworkInterface uses StringTranslationTrait
Expanded class hierarchy of Facebook
2 string references to 'Facebook'
- Facebook::getLabel in src/
SocialNetwork/ Facebook.php - Get the network name.
- social_simple.services.yml in ./
social_simple.services.yml - social_simple.services.yml
1 service uses Facebook
File
- src/
SocialNetwork/ Facebook.php, line 12
Namespace
Drupal\social_simple\SocialNetworkView source
class Facebook implements SocialNetworkInterface {
use StringTranslationTrait;
/**
* The social network base share link.
*/
const FACEBOOK_URL = 'https://www.facebook.com/sharer/sharer.php';
/**
* {@inheritdoc}
*/
public function getId() {
return 'facebook';
}
/**
* {@inheritdoc}
*/
public function getLabel() {
return $this
->t('Facebook');
}
/**
* {@inheritdoc}
*/
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;
}
/**
* {@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 |
---|---|---|---|---|
Facebook:: |
constant | The social network base share link. | ||
Facebook:: |
public | function |
Get the network id. Overrides SocialNetworkInterface:: |
|
Facebook:: |
public | function |
Get the network name. Overrides SocialNetworkInterface:: |
|
Facebook:: |
public | function |
Get common attributes for the share link. Overrides SocialNetworkInterface:: |
|
Facebook:: |
public | function |
Checks whether the given transition is allowed. Overrides SocialNetworkInterface:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
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. |