You are here

protected function Role::getNode in Search API Sort Priority 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 Role::getNode()
Role::addFieldValues in src/Plugin/search_api/processor/Role.php
Adds the values of properties defined by this processor to the item.

File

src/Plugin/search_api/processor/Role.php, line 237

Class

Role
Adds customized sort priority by Role.

Namespace

Drupal\search_api_sort_priority\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;
}