public function ExamplePreprocessEventSubscriber::preprocessPage in Hook Event Dispatcher 8.2
Same name and namespace in other branches
- 3.x examples/ExamplePreprocessEventSubscriber.php \Drupal\hook_event_dispatcher\ExamplePreprocessEventSubscriber::preprocessPage()
Preprocess a node page to set the node title as page title.
Parameters
\Drupal\preprocess_event_dispatcher\Event\PagePreprocessEvent $event: Event.
File
- examples/
ExamplePreprocessEventSubscriber.php, line 55
Class
- ExamplePreprocessEventSubscriber
- Class ExamplePreprocessorEventSubscriber.
Namespace
Drupal\hook_event_dispatcherCode
public function preprocessPage(PagePreprocessEvent $event) : void {
/** @var \Drupal\preprocess_event_dispatcher\Variables\PageEventVariables $variables */
$variables = $event
->getVariables();
$node = $variables
->getNode();
if ($node === NULL) {
return;
}
$variables
->set('title', $node
->getTitle());
}