You are here

class SocialSharingLinkedin in More Global Variables 8

Class SocialSharingLinkedin.

@package Drupal\mgv\Plugin\GlobalVariable

@Mgv( id = "social_sharing\linkedin", variableDependencies={ "current_page_title", "site_name", "current_path", "base_url", } );

Hierarchy

Expanded class hierarchy of SocialSharingLinkedin

File

src/Plugin/GlobalVariable/SocialSharingLinkedin.php, line 23

Namespace

Drupal\mgv\Plugin\GlobalVariable
View source
class SocialSharingLinkedin 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.linkedin }}">Linkedin</a>
    //
    // Share the current page on Twitter.
    return Url::fromUri('https://www.linkedin.com/shareArticle', [
      'absolute' => TRUE,
      'https' => TRUE,
      'query' => [
        'mini' => 'true',
        'url' => $this
          ->getDependency('base_url') . $this
          ->getDependency('current_path'),
        'title' => $this
          ->getDependency('current_page_title'),
        'source' => $this
          ->getDependency('site_name'),
      ],
    ])
      ->toUriString();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
GlobalVariable::$configurations private property
GlobalVariable::$dependency private property
GlobalVariable::getDependency public function Dependency getter.
GlobalVariable::__construct public function GlobalVariable constructor.
SocialSharingLinkedin::getValue public function Method that implement generating value of global variable. Overrides GlobalVariableInterface::getValue
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.