public function ExamplePreprocessorEventSubscriber::preprocessPage in Hook Event Dispatcher 8
Preprocess a node page to set the node title as page title.
Parameters
\Drupal\hook_event_dispatcher\Event\Preprocess\PagePreprocessEvent $event: Event.
File
- src/
Example/ ExamplePreprocessorEventSubscriber.php, line 30
Class
- ExamplePreprocessorEventSubscriber
- Class ExamplePreprocessorEventSubscriber.
Namespace
Drupal\hook_event_dispatcher\ExampleCode
public function preprocessPage(PagePreprocessEvent $event) {
/** @var \Drupal\hook_event_dispatcher\Event\Preprocess\Variables\PageEventVariables $variables */
$variables = $event
->getVariables();
$node = $variables
->getNode();
if ($node === NULL) {
return;
}
$variables
->set('title', $node
->getTitle());
}