On this page
public static function RouteCompiler::getFit
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\RoutingCode
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;
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Routing!RouteCompiler.php/function/RouteCompiler::getFit/8.1.x