abstract class SearchPluginDeriverBase in Search API Autocomplete 8
Provides a base class for search plugin derivers.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\search_api_autocomplete\Search\SearchPluginDeriverBase implements ContainerDeriverInterface uses StringTranslationTrait
Expanded class hierarchy of SearchPluginDeriverBase
3 files declare their use of SearchPluginDeriverBase
- PageDeriver.php in src/
Plugin/ search_api_autocomplete/ search/ PageDeriver.php - search_api_autocomplete.module in ./
search_api_autocomplete.module - Adds autocomplete capabilities for Search API searches.
- ViewsDeriver.php in src/
Plugin/ search_api_autocomplete/ search/ ViewsDeriver.php
File
- src/
Search/ SearchPluginDeriverBase.php, line 14
Namespace
Drupal\search_api_autocomplete\SearchView source
abstract class SearchPluginDeriverBase extends DeriverBase implements ContainerDeriverInterface {
use StringTranslationTrait;
/**
* Existing instances of this class.
*
* @var \Drupal\search_api_autocomplete\Search\SearchPluginDeriverBase[][]
*/
protected static $instances = [];
/**
* {@inheritdoc}
*/
protected $derivatives = NULL;
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
$deriver = new static();
$deriver
->setEntityTypeManager($container
->get('entity_type.manager'));
$deriver
->setStringTranslation($container
->get('string_translation'));
static::$instances[$base_plugin_id][] = $deriver;
return $deriver;
}
/**
* Resets the statically cached derivatives for all instances of this class.
*
* @param string|null $base_plugin_id
* (optional) If given, only reset the caches on derivers for the given base
* plugin ID.
*/
public static function resetStaticDerivativeCaches($base_plugin_id = NULL) {
$instances = static::$instances;
if ($base_plugin_id) {
$instances = !empty($instances[$base_plugin_id]) ? $instances[$base_plugin_id] : [];
}
foreach ($instances as $deriver) {
$deriver->derivatives = NULL;
}
}
/**
* Retrieves the entity manager.
*
* @return \Drupal\Core\Entity\EntityTypeManagerInterface
* The entity manager.
*/
public function getEntityTypeManager() {
return $this->entityTypeManager;
}
/**
* Sets the entity manager.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity manager.
*
* @return $this
*/
public function setEntityTypeManager(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
return $this;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
DeriverBase:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverInterface:: |
39 |
SearchPluginDeriverBase:: |
protected | property |
List of derivative definitions. Overrides DeriverBase:: |
|
SearchPluginDeriverBase:: |
protected | property | The entity manager. | |
SearchPluginDeriverBase:: |
protected static | property | Existing instances of this class. | |
SearchPluginDeriverBase:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
SearchPluginDeriverBase:: |
public | function | Retrieves the entity manager. | |
SearchPluginDeriverBase:: |
public static | function | Resets the statically cached derivatives for all instances of this class. | |
SearchPluginDeriverBase:: |
public | function | Sets the entity manager. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |