class SocialSharingEmail in More Global Variables 8
Class SocialSharingEmail.
@package Drupal\mgv\Plugin\GlobalVariable
@Mgv( id = "social_sharing\email", variableDependencies={ "current_page_title", "site_name", "base_url", "current_path", } );
Hierarchy
- class \Drupal\mgv\Plugin\GlobalVariable implements GlobalVariableInterface uses StringTranslationTrait
- class \Drupal\mgv\Plugin\GlobalVariable\SocialSharingEmail
Expanded class hierarchy of SocialSharingEmail
File
- src/
Plugin/ GlobalVariable/ SocialSharingEmail.php, line 23
Namespace
Drupal\mgv\Plugin\GlobalVariableView source
class SocialSharingEmail extends GlobalVariable {
/**
* {@inheritdoc}
*/
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.email }}">Email</a>
//
// Share the current page by Email.
return Url::fromUri('mailto:', [
'query' => [
'subject' => $this
->getDependency('current_page_title'),
'body' => $this
->t('Check this out from @sitename: :base_url:current_path', [
'@sitename' => $this
->getDependency('site_name'),
':base_url' => $this
->getDependency('base_url'),
':current_path' => $this
->getDependency('current_path'),
]),
],
])
->toUriString();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
GlobalVariable:: |
private | property | ||
GlobalVariable:: |
private | property | ||
GlobalVariable:: |
public | function | Dependency getter. | |
GlobalVariable:: |
public | function | GlobalVariable constructor. | |
SocialSharingEmail:: |
public | function |
Method that implement generating value of global variable. Overrides GlobalVariableInterface:: |
|
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. |