protected function detectCollisions(string $uri, string $cabin) : bool
{
$state = State::instance();
$ap = Gears::getName('AutoPilot');
if (!$ap instanceof AutoPilot) {
throw new \TypeError(\__('AutoPilot Blueprint'));
}
$nop = [];
foreach ($state->cabins as $pattern => $cab) {
if ($cab === $cabin) {
// Let's check each existing route in the current cabin for a collision
foreach ($cab['data']['routes'] as $route => $landing) {
$test = $ap::testLanding($ap::$patternPrefix . $route . '$', $uri, $nop, true);
if ($test) {
return true;
}
}
} else {
// Let's check each cabin route for a pattern
$test = $ap::testLanding($ap::$patternPrefix . $pattern, $uri, $nop, true);
if ($test) {
return true;
}
}
}
return \preg_match('#^(static|js|img|fonts|css)/#', $uri) === 0;
}