You are here

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

Class

CurrentPathAlias
Class CurrentPathAlias.

Namespace

Drupal\mgv\Plugin\GlobalVariable

Code

public function getValue() {

  // Print the current path alias. This could be useful if you want to ensure
  // the alias rather than the path is used.
  $current_path = \Drupal::service('path.current')
    ->getPath();
  return \Drupal::service('path_alias.manager')
    ->getAliasByPath($current_path);
}