Backend\Core\Engine\Navigation::compareURL PHP Метод

compareURL() приватный Метод

Try to determine the selected state
private compareURL ( array $value, integer $key, array $keys = [] ) : mixed
$value array The value.
$key integer The key.
$keys array The previous marked keys.
Результат mixed
    private function compareURL(array $value, $key, $keys = array())
    {
        // create active url
        $activeURL = $this->URL->getModule() . '/' . $this->URL->getAction();
        // we use the lowercased versions in the url
        $activeURL = mb_strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $activeURL));
        // add current key
        $keys[] = $key;
        // sub action?
        if (isset($value['selected_for']) && in_array($activeURL, (array) $value['selected_for'])) {
            return $keys;
        }
        // if the URL is available and same as the active one we have what we need.
        if (isset($value['url']) && $value['url'] == $activeURL) {
            if (isset($value['children'])) {
                // loop the children
                foreach ($value['children'] as $key => $value) {
                    // recursive here...
                    $subKeys = $this->compareURL($value, $key, $keys);
                    // wrap it up
                    if (!empty($subKeys)) {
                        return $subKeys;
                    }
                }
            }
            // fallback
            return $keys;
        }
        // any children
        if (isset($value['children'])) {
            // loop the children
            foreach ($value['children'] as $key => $value) {
                // recursive here...
                $subKeys = $this->compareURL($value, $key, $keys);
                // wrap it up
                if (!empty($subKeys)) {
                    return $subKeys;
                }
            }
        }
    }