Airship\Cabin\Bridge\Landing\PageManager::detectCollisions PHP Method

detectCollisions() protected method

Find probable collisions between patterns and cabin names, as well as hard-coded paths in the current cabin. It does NOT look for collisions in custom pages, nor in page collisions in foreign Cabins (outside of the Cabin itself).
protected detectCollisions ( string $uri, string $cabin ) : boolean
$uri string
$cabin string
return boolean
    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;
    }