class GenericDatabase in Search API 8
Represents any database for which no specifics are known.
Hierarchy
- class \Drupal\search_api_db\DatabaseCompatibility\GenericDatabase implements DatabaseCompatibilityHandlerInterface
Expanded class hierarchy of GenericDatabase
2 files declare their use of GenericDatabase
- BackendTest.php in modules/
search_api_db/ tests/ src/ Kernel/ BackendTest.php - Database.php in modules/
search_api_db/ src/ Plugin/ search_api/ backend/ Database.php
1 string reference to 'GenericDatabase'
- search_api_db.services.yml in modules/
search_api_db/ search_api_db.services.yml - modules/search_api_db/search_api_db.services.yml
1 service uses GenericDatabase
File
- modules/
search_api_db/ src/ DatabaseCompatibility/ GenericDatabase.php, line 12
Namespace
Drupal\search_api_db\DatabaseCompatibilityView source
class GenericDatabase implements DatabaseCompatibilityHandlerInterface {
/**
* The connection to the database.
*
* @var \Drupal\Core\Database\Connection
*/
protected $database;
/**
* The transliteration service to use.
*
* @var \Drupal\Component\Transliteration\TransliterationInterface
*/
protected $transliterator;
/**
* Constructs a GenericDatabase object.
*
* @param \Drupal\Core\Database\Connection $database
* The connection to the database.
* @param \Drupal\Component\Transliteration\TransliterationInterface $transliterator
* The transliteration service to use.
*/
public function __construct(Connection $database, TransliterationInterface $transliterator) {
$this->database = $database;
$this->transliterator = $transliterator;
}
/**
* {@inheritdoc}
*/
public function getDatabase() {
return $this->database;
}
/**
* {@inheritdoc}
*/
public function getCloneForDatabase(Connection $database) {
$service = clone $this;
$service->database = $database;
return $service;
}
/**
* {@inheritdoc}
*/
public function alterNewTable($table, $type = 'text') {
}
/**
* {@inheritdoc}
*/
public function preprocessIndexValue($value, $type = 'text') {
if ($type == 'text') {
return $value;
}
return mb_strtolower($this->transliterator
->transliterate($value));
}
/**
* {@inheritdoc}
*/
public function orderByRandom(SelectInterface $query) {
$alias = $query
->addExpression('random()', 'random_order_field');
$query
->orderBy($alias);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
GenericDatabase:: |
protected | property | The connection to the database. | |
GenericDatabase:: |
protected | property | The transliteration service to use. | |
GenericDatabase:: |
public | function |
Reacts to a new table being created. Overrides DatabaseCompatibilityHandlerInterface:: |
1 |
GenericDatabase:: |
public | function |
Creates a clone of this service for the given database. Overrides DatabaseCompatibilityHandlerInterface:: |
|
GenericDatabase:: |
public | function |
Retrieves the database connection this compatibility handler is based upon. Overrides DatabaseCompatibilityHandlerInterface:: |
|
GenericDatabase:: |
public | function |
Applies a random sort to the query. Overrides DatabaseCompatibilityHandlerInterface:: |
1 |
GenericDatabase:: |
public | function |
Determines the canonical base form of a value. Overrides DatabaseCompatibilityHandlerInterface:: |
2 |
GenericDatabase:: |
public | function | Constructs a GenericDatabase object. |