You are here

class SuperUser in Open Social 10.0.x

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

Adds access checks for profiles.

Plugin annotation


@SearchApiProcessor(
  id = "super_user",
  label = @Translation("Skip User 1"),
  description = @Translation("Makes sure that user 1 is not added to the index."),
  stages = {
    "alter_items" = 0,
  },
)

Hierarchy

  • class \Drupal\social_search\Plugin\search_api\processor\SuperUser extends \Drupal\search_api\Processor\ProcessorPluginBase

Expanded class hierarchy of SuperUser

File

modules/social_features/social_search/src/Plugin/search_api/processor/SuperUser.php, line 22

Namespace

Drupal\social_search\Plugin\search_api\processor
View source
class SuperUser extends ProcessorPluginBase {

  /**
   * {@inheritdoc}
   */
  public static function supportsIndex(IndexInterface $index) {
    $supported_entity_types = [
      'profile',
    ];
    foreach ($index
      ->getDatasources() as $datasource) {
      if (in_array($datasource
        ->getEntityTypeId(), $supported_entity_types)) {
        return TRUE;
      }
    }
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  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
          ->getOwnerId() == '1') {
          unset($items[$item_id]);
        }
      }
      elseif ($object instanceof UserInterface) {
        if ($object
          ->id() == '1') {
          unset($items[$item_id]);
        }
      }
    }
  }

}

Members