class UserSearch

Same name and namespace in other branches
  1. 11.x core/modules/user/src/Plugin/Search/UserSearch.php \Drupal\user\Plugin\Search\UserSearch
  2. 10 core/modules/user/src/Plugin/Search/UserSearch.php \Drupal\user\Plugin\Search\UserSearch
  3. 9 core/modules/user/src/Plugin/Search/UserSearch.php \Drupal\user\Plugin\Search\UserSearch
  4. 8.9.x core/modules/user/src/Plugin/Search/UserSearch.php \Drupal\user\Plugin\Search\UserSearch

Executes a keyword search for users against the {users} database table.

Attributes

#[Search(id: 'user_search', title: new TranslatableMarkup('Users'))]

Hierarchy

Expanded class hierarchy of UserSearch

Deprecated

in drupal:11.5.0 and is removed from drupal:12.0.0. Instead, use \Drupal\search_user\Plugin\Search\SearchUser.

See also

https://www.drupal.org/node/3590230

File

core/modules/user/src/Plugin/Search/UserSearch.php, line 24

Namespace

Drupal\user\Plugin\Search
View source
class UserSearch extends SearchPluginBase implements AccessibleInterface {
  
  /**
   * The database connection.
   *
   * @var \Drupal\Core\Database\Connection
   */
  protected $database;
  
  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;
  
  /**
   * The module handler.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;
  
  /**
   * The current user.
   *
   * @var \Drupal\Core\Session\AccountInterface
   */
  protected $currentUser;
  
  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($container->get('database'), $container->get('entity_type.manager'), $container->get('module_handler'), $container->get('current_user'), $configuration, $plugin_id, $plugin_definition);
  }
  
  /**
   * Creates a UserSearch object.
   *
   * @param \Drupal\Core\Database\Connection $database
   *   The database connection.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler.
   * @param \Drupal\Core\Session\AccountInterface $current_user
   *   The current user.
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin ID for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   */
  public function __construct(Connection $database, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, AccountInterface $current_user, array $configuration, $plugin_id, $plugin_definition) {
    @trigger_error(__CLASS__ . ' is deprecated in drupal:11.5.0 and is removed from drupal:12.0.0. Instead, use \\Drupal\\search_user\\Plugin\\Search\\SearchUser See https://www.drupal.org/node/3590230', E_USER_DEPRECATED);
    $this->database = $database;
    $this->entityTypeManager = $entity_type_manager;
    $this->moduleHandler = $module_handler;
    $this->currentUser = $current_user;
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->addCacheTags([
      'user_list',
    ]);
  }
  
  /**
   * {@inheritdoc}
   */
  public function access($operation = 'view', ?AccountInterface $account = NULL, $return_as_object = FALSE) : AccessResult {
    return AccessResult::forbidden();
  }
  
  /**
   * {@inheritdoc}
   */
  public function execute() : array {
    return [];
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
AutowiredInstanceTrait::createInstanceAutowired public static function Instantiates a new instance of the implementing class using autowiring.
AutowiredInstanceTrait::getAutowireArguments private static function Resolves arguments for a method using autowiring.
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::getCacheContexts public function 4
CacheableDependencyTrait::getCacheMaxAge public function 4
CacheableDependencyTrait::getCacheTags public function 4
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 2
DependencySerializationTrait::__wakeup public function 2
MessengerTrait::$messenger protected property The messenger. 26
MessengerTrait::messenger public function Gets the messenger. 26
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin ID.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Overrides PluginInspectionInterface::getPluginDefinition 2
PluginBase::getPluginId public function Overrides PluginInspectionInterface::getPluginId
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function
SearchPluginBase::$keywords protected property The keywords to use in a search.
SearchPluginBase::$searchAttributes protected property Array of attributes - usually from the request object.
SearchPluginBase::$searchParameters protected property Array of parameters from the query string from the request.
SearchPluginBase::buildResults public function Overrides SearchInterface::buildResults 1
SearchPluginBase::buildSearchUrlQuery public function Overrides SearchInterface::buildSearchUrlQuery 1
SearchPluginBase::getAttributes public function Overrides SearchInterface::getAttributes
SearchPluginBase::getKeywords public function Overrides SearchInterface::getKeywords
SearchPluginBase::getParameters public function Overrides SearchInterface::getParameters
SearchPluginBase::getType public function Overrides SearchInterface::getType 2
SearchPluginBase::isSearchExecutable public function Overrides SearchInterface::isSearchExecutable 2
SearchPluginBase::searchFormAlter public function Overrides SearchInterface::searchFormAlter 1
SearchPluginBase::setSearch public function Overrides SearchInterface::setSearch 1
SearchPluginBase::suggestedTitle public function Overrides SearchInterface::suggestedTitle
SearchPluginBase::usesAdminTheme public function Overrides SearchInterface::usesAdminTheme
StringTranslationTrait::$stringTranslation protected property The string translation service. 3
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language. 1
UserSearch::$currentUser protected property The current user.
UserSearch::$database protected property The database connection.
UserSearch::$entityTypeManager protected property The entity type manager.
UserSearch::$moduleHandler protected property The module handler.
UserSearch::access public function Overrides AccessibleInterface::access
UserSearch::create public static function Overrides PluginBase::create
UserSearch::execute public function Overrides SearchInterface::execute
UserSearch::__construct public function Creates a UserSearch object. Overrides PluginBase::__construct

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.