You are here

private static function PathChecker::collectAlias in Optimizely 8.3

Lookup all alternatives to the group of paths - alias, <front>.

Parameters

array $paths: A set of paths to be reviewed for alternatives.

Return value

array An updated list of paths that include the additional source and alias values.

1 call to PathChecker::collectAlias()
PathChecker::uniquePaths in src/Util/PathChecker.php
Compare target path against the project paths to confirm they're unique.

File

src/Util/PathChecker.php, line 218

Class

PathChecker
Provides static methods to check path validity, etc.

Namespace

Drupal\optimizely\Util

Code

private static function collectAlias(array $paths) {

  // Add alternative values - alias, source, <front> to ensure matches
  // also check different possibilities.
  foreach ($paths as $path_count => $path) {

    // Remove parameters.
    if (strpos($path, '?') !== FALSE) {
      $path = substr($path, 0, strpos($path, '?'));
      $paths[$path_count] = $path;
    }
    if (self::lookupPathAlias($path)) {
      $paths[] = self::lookupPathAlias($path);
    }
    if (self::lookupSystemPath($path)) {
      $paths[] = self::lookupSystemPath($path);
    }

    // Collect all the possible values to match <front>.
    if ($path == '<front>') {
      $frontpage = \Drupal::config('system.site')
        ->get('page.front');
      if ($frontpage) {
        $paths[] = $frontpage;
        $paths[] = self::lookupPathAlias($frontpage);
      }
    }
  }
  return $paths;
}