public static RouteCompiler::getFit($path)
Determines the fitness of the provided path.
Parameters
string $path: The path whose fitness we want.
Return value
int The fitness of the path, as an integer.
File
- core/lib/Drupal/Core/Routing/RouteCompiler.php, line 86
Class
- RouteCompiler
- Compiler to generate derived information from a Route necessary for matching.
Namespace
Drupal\Core\Routing
Code
public static function getFit($path) { $parts = explode('/', trim($path, '/')); $number_parts = count($parts); // We store the highest index of parts here to save some work in the fit // calculation loop. $slashes = $number_parts - 1; // The fit value is a binary number which has 1 at every fixed path // position and 0 where there is a wildcard. We keep track of all such // patterns that exist so that we can minimize the number of path // patterns we need to check in the RouteProvider. $fit = 0; foreach ($parts as $k => $part) { if (strpos($part, '{') === FALSE) { $fit |= 1 << ($slashes - $k); } } return $fit; }
Please login to continue.