You are here

protected function ContentAccess::getNode in Search API 8

Retrieves the node related to an indexed search object.

Will be either the node itself, or the node the comment is attached to.

Parameters

\Drupal\Core\TypedData\ComplexDataInterface $item: A search object that is being indexed.

Return value

\Drupal\node\NodeInterface|null The node related to that search object.

1 call to ContentAccess::getNode()
ContentAccess::addFieldValues in src/Plugin/search_api/processor/ContentAccess.php
Adds the values of properties defined by this processor to the item.

File

src/Plugin/search_api/processor/ContentAccess.php, line 221

Class

ContentAccess
Adds content access checks for nodes and comments.

Namespace

Drupal\search_api\Plugin\search_api\processor

Code

protected function getNode(ComplexDataInterface $item) {
  $item = $item
    ->getValue();
  if ($item instanceof CommentInterface) {
    $item = $item
      ->getCommentedEntity();
  }
  if ($item instanceof NodeInterface) {
    return $item;
  }
  return NULL;
}