class RawCurrentPageTitle in More Global Variables 8
Class RawCurrentPageTitle.
@package Drupal\mgv\Plugin\GlobalVariable
@Mgv( id = "raw_current_page_title", );
Hierarchy
- class \Drupal\mgv\Plugin\GlobalVariable implements GlobalVariableInterface uses StringTranslationTrait
- class \Drupal\mgv\Plugin\GlobalVariable\RawCurrentPageTitle
Expanded class hierarchy of RawCurrentPageTitle
File
- src/
Plugin/ GlobalVariable/ RawCurrentPageTitle.php, line 17
Namespace
Drupal\mgv\Plugin\GlobalVariableView source
class RawCurrentPageTitle extends GlobalVariable {
/**
* {@inheritdoc}
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
GlobalVariable:: |
private | property | ||
GlobalVariable:: |
private | property | ||
GlobalVariable:: |
public | function | Dependency getter. | |
GlobalVariable:: |
public | function | GlobalVariable constructor. | |
RawCurrentPageTitle:: |
public | function |
Method that implement generating value of global variable. Overrides GlobalVariableInterface:: |
1 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |