class IndexManager in Drupal driver for SQL Server and SQL Azure 8.2
Same name and namespace in other branches
- 8 src/Indexes/IndexManager.php \Drupal\sqlsrv\Indexes\IndexManager
Default indexes to be deployed for CORE functionality.
Hierarchy
- class \Drupal\sqlsrv\Indexes\IndexManager
Expanded class hierarchy of IndexManager
1 file declares its use of IndexManager
- sqlsrv.install in ./
sqlsrv.install - Installation file for sqlsrv module.
File
- src/
Indexes/ IndexManager.php, line 11
Namespace
Drupal\sqlsrv\IndexesView source
class IndexManager {
/**
* Summary of $connection
*
* @var Connection
*/
private $connection;
/**
* Path to the index folder.
*
* @var string
*/
private $path;
/**
* Creates an instance of DefaultIndexes with a all defined indexes.
*
* @param Connection $connection
* Database connection.
* @param string $path
* Path to the index folder.
*/
public function __construct(Connection $connection, $path) {
$this->connection = $connection;
$this->path = $path;
}
/**
* Deploy all missing indexes.
*
* @return void
* @throws \Exception
*
*/
public function DeployNew() {
/**
* @var FileSystem $fileSystem
*/
$fileSystem = \Drupal::service('file_system');
// Scan the Implementations folder
$dir = $this->path;
$files = $fileSystem
->scanDirectory($dir, '/.*\\.sql$/');
foreach ($files as $file) {
$index = new Index($file->uri);
$table = $this->connection
->prefixTable($index
->GetTable());
$name = $index
->GetName();
$schema = $this->connection
->Scheme();
if (!$schema
->indexExists($table, $name) && $schema
->TableExists($table)) {
try {
// TODO: Consider the need to prefix the tables...
$this->connection
->GetConnection()
->query_execute($index
->GetCode());
} catch (\Exception $e) {
\Drupal::logger('MSSQL')
->notice("Could not deploy index {$name} for table {$table}");
}
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
IndexManager:: |
private | property | Summary of $connection | |
IndexManager:: |
private | property | Path to the index folder. | |
IndexManager:: |
public | function | Deploy all missing indexes. | |
IndexManager:: |
public | function | Creates an instance of DefaultIndexes with a all defined indexes. |