protected function AliasManager::pathAliasWhitelistRebuild

Rebuild the path alias white list.

Parameters

$source: An optional system path for which an alias is being inserted.

Return value

An array containing a white list of path aliases.

2 calls to AliasManager::pathAliasWhitelistRebuild()
AliasManager::cacheClear in drupal/core/lib/Drupal/Core/Path/AliasManager.php
Implements \Drupal\Core\Path\AliasManagerInterface::cacheClear().
AliasManager::__construct in drupal/core/lib/Drupal/Core/Path/AliasManager.php

File

drupal/core/lib/Drupal/Core/Path/AliasManager.php, line 299
Contains Drupal\Core\Path\AliasManager.

Class

AliasManager

Namespace

Drupal\Core\Path

Code

protected function pathAliasWhitelistRebuild($source = NULL) {

  // When paths are inserted, only rebuild the whitelist if the system path
  // has a top level component which is not already in the whitelist.
  if (!empty($source)) {

    // @todo Inject state so we don't have this function call.
    $whitelist = $this->state
      ->get('system.path_alias_whitelist', NULL);
    if (isset($whitelist[strtok($source, '/')])) {
      return $whitelist;
    }
  }

  // For each alias in the database, get the top level component of the system
  // path it corresponds to. This is the portion of the path before the first
  // '/', if present, otherwise the whole path itself.
  $whitelist = array();
  $result = $this->connection
    ->query("SELECT DISTINCT SUBSTRING_INDEX(source, '/', 1) AS path FROM {url_alias}");
  foreach ($result as $row) {
    $whitelist[$row->path] = TRUE;
  }
  $this->state
    ->set('system.path_alias_whitelist', $whitelist);
  return $whitelist;
}