You are here

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

Class

SocialSharingWhatsapp
Class SocialSharingWhatsapp.

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.whatsapp }}">Whatsapp</a>
  //
  // Share the current page on Whatsapp.
  return Url::fromUri('whatsapp://send', [
    'absolute' => TRUE,
    'query' => [
      'text' => $this
        ->getDependency('current_page_title') . ' - ' . $this
        ->getDependency('base_url') . $this
        ->getDependency('current_path'),
    ],
  ])
    ->toUriString();
}