You are here

public function BlockedUsers::alterIndexedItems in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_search/src/Plugin/search_api/processor/BlockedUsers.php \Drupal\social_search\Plugin\search_api\processor\BlockedUsers::alterIndexedItems()
  2. 8.2 modules/social_features/social_search/src/Plugin/search_api/processor/BlockedUsers.php \Drupal\social_search\Plugin\search_api\processor\BlockedUsers::alterIndexedItems()
  3. 8.3 modules/social_features/social_search/src/Plugin/search_api/processor/BlockedUsers.php \Drupal\social_search\Plugin\search_api\processor\BlockedUsers::alterIndexedItems()
  4. 8.4 modules/social_features/social_search/src/Plugin/search_api/processor/BlockedUsers.php \Drupal\social_search\Plugin\search_api\processor\BlockedUsers::alterIndexedItems()
  5. 8.5 modules/social_features/social_search/src/Plugin/search_api/processor/BlockedUsers.php \Drupal\social_search\Plugin\search_api\processor\BlockedUsers::alterIndexedItems()
  6. 8.6 modules/social_features/social_search/src/Plugin/search_api/processor/BlockedUsers.php \Drupal\social_search\Plugin\search_api\processor\BlockedUsers::alterIndexedItems()
  7. 8.7 modules/social_features/social_search/src/Plugin/search_api/processor/BlockedUsers.php \Drupal\social_search\Plugin\search_api\processor\BlockedUsers::alterIndexedItems()
  8. 8.8 modules/social_features/social_search/src/Plugin/search_api/processor/BlockedUsers.php \Drupal\social_search\Plugin\search_api\processor\BlockedUsers::alterIndexedItems()
  9. 10.3.x modules/social_features/social_search/src/Plugin/search_api/processor/BlockedUsers.php \Drupal\social_search\Plugin\search_api\processor\BlockedUsers::alterIndexedItems()
  10. 10.0.x modules/social_features/social_search/src/Plugin/search_api/processor/BlockedUsers.php \Drupal\social_search\Plugin\search_api\processor\BlockedUsers::alterIndexedItems()
  11. 10.1.x modules/social_features/social_search/src/Plugin/search_api/processor/BlockedUsers.php \Drupal\social_search\Plugin\search_api\processor\BlockedUsers::alterIndexedItems()
  12. 10.2.x modules/social_features/social_search/src/Plugin/search_api/processor/BlockedUsers.php \Drupal\social_search\Plugin\search_api\processor\BlockedUsers::alterIndexedItems()

Alter the items to be indexed.

Parameters

\Drupal\search_api\Item\ItemInterface[] $items: An array of items to be indexed, passed by reference.

Overrides ProcessorPluginBase::alterIndexedItems

File

modules/social_features/social_search/src/Plugin/search_api/processor/BlockedUsers.php, line 45

Class

BlockedUsers
Ignores blocked users in index and queries.

Namespace

Drupal\social_search\Plugin\search_api\processor

Code

public function alterIndexedItems(array &$items) {
  foreach ($items as $item_id => $item) {
    $object = $item
      ->getOriginalObject()
      ->getValue();
    if ($object instanceof ProfileInterface) {

      // Profile ownedId is the userId.
      if ($object
        ->getOwner()
        ->isBlocked() === TRUE) {
        unset($items[$item_id]);
      }
    }
    elseif ($object instanceof UserInterface) {
      if ($object
        ->isBlocked() === TRUE) {
        unset($items[$item_id]);
      }
    }
  }
}