function getCurrentTrail($offset = 0) { if (!isset($this->cachedTrail)) { $request = $this->request(); if (is_null($request)) { throw new Fault(Faults::REQUEST_NOT_SET); } $url = $request->getAttribute('virtualUri'); $this->currentLink = null; $this->cachedTrail = []; $this->buildTrail($this->rootLink, $this->cachedTrail, $url); if ($this->currentLink) { if ($this->currentLink === $this->selectedLink) { $this->currentLink->setState(true, true, true); } else { $this->currentLink->setState(true, false, true); if ($this->selectedLink) { $this->selectedLink->setState(true, true, false); } } } } return $offset ? array_slice($this->cachedTrail, $offset) : $this->cachedTrail; }