You are here

private static function PathChecker::duplicateCheck in Optimizely 8.0

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

File

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

Class

PathChecker
Provides static methods to check path validity, etc.

Namespace

Drupal\optimizely

Code

private static function duplicateCheck($paths) {
  $unreviewed_paths = $paths;

  // Check all of the paths
  foreach ($paths as $path) {

    // Remove path that's being processed from the front of the list
    array_shift($unreviewed_paths);

    // "*" found in path
    if (strpos($path, '*') !== FALSE) {

      // Look for wild card match that's not sitewide (position not zero (0))
      if (strpos($path, '*') !== 0) {
        $path = substr($path, 0, -2);
        foreach ($unreviewed_paths as $unreviewed_path) {
          if (strpos($unreviewed_path, $path) !== FALSE) {
            return $path . '/*';
          }
        }
      }
      elseif (strpos($path, '*') === 0 && count($paths) > 1) {
        return $path;
      }
    }
    elseif (in_array($path, $unreviewed_paths)) {
      return $path;
    }
  }
  return FALSE;
}