You are here

public function SocialSharingEmail::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/SocialSharingEmail.php, line 28

Class

SocialSharingEmail
Class SocialSharingEmail.

Namespace

Drupal\mgv\Plugin\GlobalVariable

Code

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();
}