public function RawCurrentPageTitle::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
1 call to RawCurrentPageTitle::getValue()
- CurrentPageTitle::getValue in src/
Plugin/ GlobalVariable/ CurrentPageTitle.php - Method that implement generating value of global variable.
1 method overrides RawCurrentPageTitle::getValue()
- CurrentPageTitle::getValue in src/
Plugin/ GlobalVariable/ CurrentPageTitle.php - Method that implement generating value of global variable.
File
- src/
Plugin/ GlobalVariable/ RawCurrentPageTitle.php, line 22
Class
- RawCurrentPageTitle
- Class RawCurrentPageTitle.
Namespace
Drupal\mgv\Plugin\GlobalVariableCode
public function getValue() {
// Print the current page's title. This could be useful if you want to add
// the current page title as a breadcrumb.
$request = \Drupal::request();
if ($route = $request->attributes
->get(RouteObjectInterface::ROUTE_OBJECT)) {
$title = \Drupal::service('title_resolver')
->getTitle($request, $route);
}
return empty($title) ? '' : $title;
}