You are here

private static function PathChecker::collectAlias in Optimizely 8.0

Same name and namespace in other branches
  1. 8 src/PathChecker.php \Drupal\optimizely\PathChecker::collectAlias()
1 call to PathChecker::collectAlias()
PathChecker::uniquePaths in src/PathChecker.php

File

src/PathChecker.php, line 217
Contains \Drupal\optimizely\src\PathChecker

Class

PathChecker
Provides static methods to check path validity, etc.

Namespace

Drupal\optimizely

Code

private static function collectAlias($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;
    }
    !self::lookupPathAlias($path) ?: ($paths[] = self::lookupPathAlias($path));
    !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;
}