You are here

private function PageContext::setContextByNode in Acquia Lift Connector 8.3

Same name and namespace in other branches
  1. 8.4 src/Service/Context/PageContext.php \Drupal\acquia_lift\Service\Context\PageContext::setContextByNode()

Set page context by Node.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request object.

1 call to PageContext::setContextByNode()
PageContext::__construct in src/Service/Context/PageContext.php
Constructor.

File

src/Service/Context/PageContext.php, line 158

Class

PageContext

Namespace

Drupal\acquia_lift\Service\Context

Code

private function setContextByNode(Request $request) {

  // If not a request to node, do nothing.
  if (!$request->attributes
    ->has('node')) {
    return;
  }
  $node = $request->attributes
    ->get('node');
  if (empty($node) || !$node instanceof NodeInterface) {
    return;
  }

  // Otherwise, set page context by node.
  $this
    ->setNodeData($node);
  $this
    ->setFields($node);
}