You are here

public function AliasStorage::getAliasesForAdminListing in Multiversion 8

Loads aliases for admin listing.

Parameters

array $header: Table header.

string|null $keys: (optional) Search keyword that may include one or more '*' as wildcard values.

Return value

array Array of items to be displayed on the current page.

Overrides AliasStorage::getAliasesForAdminListing

File

src/AliasStorage.php, line 303

Class

AliasStorage
Extends the core AliasStore class. We need this to make possible aliases to work with Multiversion and Replication.

Namespace

Drupal\multiversion

Code

public function getAliasesForAdminListing($header, $keys = NULL) {
  if (!$this->connection
    ->schema()
    ->fieldExists('url_alias', 'workspace')) {
    return parent::getAliasesForAdminListing($header, $keys);
  }
  $query = $this->connection
    ->select(static::TABLE)
    ->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender')
    ->extend('Drupal\\Core\\Database\\Query\\TableSortExtender');
  $query
    ->condition('workspace', [
    $this->workspaceManager
      ->getActiveWorkspaceId(),
    0,
  ], 'IN');
  if ($keys) {

    // Replace wildcards with PDO wildcards.
    $query
      ->condition('alias', '%' . preg_replace('!\\*+!', '%', $keys) . '%', 'LIKE');
  }
  try {
    return $query
      ->fields(static::TABLE)
      ->orderByHeader($header)
      ->limit(50)
      ->execute()
      ->fetchAll();
  } catch (\Exception $e) {
    $this
      ->catchException($e);
    return [];
  }
}