public function SocialSharingTwitter::getValue in More Global Variables 8
Method that implement generating value of global variable.
Return value
mixed Return value of declared variable.
Overrides GlobalVariableInterface::getValue
File
- src/
Plugin/ GlobalVariable/ SocialSharingTwitter.php, line 27
Class
- SocialSharingTwitter
- Class SocialSharingTwitter.
Namespace
Drupal\mgv\Plugin\GlobalVariableCode
public function getValue() {
// Social Sharing Global Variables
//
// To use this, you need to wrap the variable in an anchor tag, such as:
// <a href="{{ global_variables.social_sharing.twitter }}">Twitter</a>
//
// Share the current page on Twitter.
return Url::fromUri('https://twitter.com/share', [
'absolute' => TRUE,
'https' => TRUE,
'query' => [
'url' => $this
->getDependency('base_url') . $this
->getDependency('current_path'),
'text' => $this
->getDependency('current_page_title'),
],
])
->toUriString();
}