You are here

public function ExamplePreprocessEventSubscriber::preprocessArticleFull in Hook Event Dispatcher 3.x

Same name and namespace in other branches
  1. 8.2 examples/ExamplePreprocessEventSubscriber.php \Drupal\hook_event_dispatcher\ExamplePreprocessEventSubscriber::preprocessArticleFull()

Preprocess a node with bundle type article in view mode full.

Parameters

\Drupal\preprocess_event_dispatcher\Event\NodePreprocessEvent $event: Event.

File

examples/ExamplePreprocessEventSubscriber.php, line 41

Class

ExamplePreprocessEventSubscriber
Class ExamplePreprocessorEventSubscriber.

Namespace

Drupal\hook_event_dispatcher

Code

public function preprocessArticleFull(NodePreprocessEvent $event) : void {

  /** @var \Drupal\preprocess_event_dispatcher\Variables\NodeEventVariables $variables */
  $variables = $event
    ->getVariables();
  $node = $variables
    ->getNode();
  $someField = $node
    ->get('field_some_field')
    ->view();
  $variables
    ->set('some_field', $someField);
}