public static function SimplemetaEntity::calculateFit in Simple Meta 8
Same name and namespace in other branches
- 8.2 src/Entity/SimplemetaEntity.php \Drupal\simplemeta\Entity\SimplemetaEntity::calculateFit()
Calculate how much specific the path is.
Parameters
string $path: Page path to calculate a fit for.
Return value
int A numeric representation of how specific the path is.
1 call to SimplemetaEntity::calculateFit()
- SimplemetaEntity::preSave in src/
Entity/ SimplemetaEntity.php - Acts on an entity before the presave hook is invoked.
File
- src/
Entity/ SimplemetaEntity.php, line 124
Class
- SimplemetaEntity
- Defines the SimpleMeta entity.
Namespace
Drupal\simplemeta\EntityCode
public static function calculateFit($path) {
$fit = 0;
$parts = explode('/', trim($path, '/'));
$number_parts = count($parts);
$slashes = $number_parts - 1;
foreach ($parts as $k => $part) {
if ($part != '*') {
$fit |= 1 << $slashes - $k;
}
}
return $fit;
}