subsiteId = $id; return $this; } /** * Get the subsite ID to use when generating the tree * * @return int */ public function getSubsiteId() { return $this->subsiteId; } /** * Get the CMS tree with the provided subsite ID applied to the state * * {@inheritDoc} */ public function tree(HTTPRequest $request) { // Detect subsite ID from the request if ($request->getVar($this->getName() . '_SubsiteID')) { $this->setSubsiteId($request->getVar($this->getName() . '_SubsiteID')); } $results = SubsiteState::singleton()->withState(function (SubsiteState $newState) use ($request) { $newState->setSubsiteId($this->getSubsiteId()); return parent::tree($request); }); return $results; } }