Jarves\Twig\NodeIsActiveExtension::isActive PHP Method

isActive() public method

public isActive ( Node | integer | string $id, boolean $exact = false ) : boolean
$id Jarves\Model\Node | integer | string Node, node id, or node url
$exact boolean whether it should also return true when a children is active
return boolean
    public function isActive($id, $exact = false)
    {
        $current = $this->pageStack->getCurrentPage();
        $url = $this->pageStack->getNodeUrl($current, true, true);
        $purl = $this->pageStack->getNodeUrl($id, true, true);
        if ($url === $purl) {
            return true;
        }
        if (!$exact) {
            if ($url && $purl) {
                $pos = strpos($url, $purl);
                if ($url == '/' || $pos != 0 || $pos === false) {
                    return false;
                } else {
                    return true;
                }
            }
        }
    }