You are here

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

Class

SocialSharingFacebook
Class SocialSharingFacebook.

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.facebook }}">Facebook</a>
  //
  // Share the current page on Facebook.
  return Url::fromUri('https://www.facebook.com/sharer.php', [
    'absolute' => TRUE,
    'https' => TRUE,
    'query' => [
      'u' => $this
        ->getDependency('base_url') . $this
        ->getDependency('current_path'),
      'text' => $this
        ->getDependency('current_page_title'),
    ],
  ])
    ->toUriString();
}