public static function Utils::DeployCustomFunctions in Drupal driver for SQL Server and SQL Azure 8
Same name and namespace in other branches
- 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/Utils.php \Drupal\Driver\Database\sqlsrv\Utils::DeployCustomFunctions()
- 3.0.x drivers/lib/Drupal/Driver/Database/sqlsrv/Utils.php \Drupal\Driver\Database\sqlsrv\Utils::deployCustomFunctions()
Deploy custom functions for Drupal Compatiblity.
Parameters
Connection $connection : Connection used for deployment.
boolean $redeploy: Wether to redeploy existing functions, or only missing ones.
2 calls to Utils::DeployCustomFunctions()
- sqlsrv_requirements in ./
sqlsrv.install - Implements hook_requirements().
- Tasks::initializeDatabase in drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Install/ Tasks.php - Make SQLServer Drupal friendly.
File
- drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Utils.php, line 158
Class
Namespace
Drupal\Driver\Database\sqlsrvCode
public static function DeployCustomFunctions(Connection $connection, $redeploy = FALSE) {
$yaml = new Parser();
$base_path = dirname(__FILE__) . '/Programability';
$configuration = $yaml
->parse(file_get_contents("{$base_path}/configuration.yml"));
/** @var Schema $schema */
$schema = $connection
->schema();
foreach ($configuration['functions'] as $function) {
$name = $function['name'];
$path = "{$base_path}/{$function['file']}";
$exists = $schema
->functionExists($name);
if ($exists && !$redeploy) {
continue;
}
if ($exists) {
$connection
->query_direct("DROP FUNCTION [{$name}]");
}
$script = trim(static::remove_utf8_bom(file_get_contents($path)));
$connection
->query_direct($script);
}
}