/** * Sitetree getter, caches the whole sitetree per logged in user groups. * If a $partialChild is defined then the cache is bypassed and a partial sitetree is returned. * * @param Int $id Optional id used to define the parent to kick off from. * @param SiteTree $partialChild Optional partial child to get a site tree section from root. */ public function getStructure($id = 0, $partialChild = null) { if (!Member::currentUserID()) { throw new Exception('SiteTreeOrigamiApi::getStructure Not logged in'); } if ($partialChild) { $stack = array_reverse($partialChild->parentStack()); $result = $this->_structure($id, $stack); } else { // Check the cache. SS_Cache::set_cache_lifetime('SiteTree_Groups', 60 * 60); //one hour $cache = SS_Cache::factory('SiteTree_Groups', 'Output', array('automatic_serialization' => true)); // If there isn't a cached response call the API. if (!($result = $cache->load(SiteTreeOrigamiApi::get_cache_key()))) { $result = $this->_structure($id); $cache->save($result, SiteTreeOrigamiApi::get_cache_key()); } } return $result; }