You are here

public static function Utils::DeployCustomFunctions in Drupal driver for SQL Server and SQL Azure 8.2

Same name and namespace in other branches
  1. 8 drivers/lib/Drupal/Driver/Database/sqlsrv/Utils.php \Drupal\Driver\Database\sqlsrv\Utils::DeployCustomFunctions()
  2. 3.0.x drivers/lib/Drupal/Driver/Database/sqlsrv/Utils.php \Drupal\Driver\Database\sqlsrv\Utils::deployCustomFunctions()

Deploy custom functions.

Parameters

\PDO $connection: Connection used for deployment.

boolean $redeploy: Whether to redeploy existing functions, or only missing ones.

1 call to Utils::DeployCustomFunctions()
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 80

Class

Utils

Namespace

Drupal\Driver\Database\sqlsrv

Code

public static function DeployCustomFunctions(Connection $connection, $base_path, $redeploy = false) {
  $yaml = new Parser();
  $configuration = $yaml
    ->parse(file_get_contents("{$base_path}/configuration.yml"));
  foreach ($configuration['functions'] as $function) {
    $name = $function['name'];
    $path = "{$base_path}/{$function['file']}";
    $exists = $connection
      ->Scheme()
      ->functionExists($name);
    if ($exists && !$redeploy) {
      continue;
    }
    if ($exists) {
      $connection
        ->Scheme()
        ->FunctionDrop($name);
    }
    $script = trim(static::removeUtf8Bom(file_get_contents($path)));
    $connection
      ->query_execute($script);
  }
}