You are here

protected function ImgTagToEmbedFilter::getProbableDomainNames in Media Migration 8

Gets the probable domain names by inspecting the watchdog table.

Parameters

\Drupal\Core\Database\Connection $connection: The source database connection.

Return value

string[] The probable domain names.

1 call to ImgTagToEmbedFilter::getProbableDomainNames()
ImgTagToEmbedFilter::transform in src/Plugin/migrate/process/ImgTagToEmbedFilter.php
Performs the associated process.

File

src/Plugin/migrate/process/ImgTagToEmbedFilter.php, line 288

Class

ImgTagToEmbedFilter
Transforms <img src="/files/cat.png"> tags to <drupal-media …>.

Namespace

Drupal\media_migration\Plugin\migrate\process

Code

protected function getProbableDomainNames(Connection $connection) : array {
  try {
    $query = $connection
      ->select('watchdog', 'w');
    $query
      ->addExpression('DISTINCT (SUBSTR(SUBSTR(location, INSTR(location, \'//\') + 2), 1, INSTR(SUBSTR(location, INSTR(location, \'//\') + 2), \'/\') - 1))');
    $result = $query
      ->execute()
      ->fetchAll();
  } catch (\Exception $e) {
    return [];
  }
  $domain_names = [];
  foreach ($result as $row) {
    $domain_names[] = $row->expression;
  }
  return $domain_names;
}