/** * Loads the sitemap tree from config or cache * If loading from config, caches the result * * @return NodePub\Navigation\SitemapTree */ public function load() { $sitemapTree = new SitemapTree('root'); $sitemapTree->setIsRoot(true); $cache = new SitemapCache($this->cacheFile); if ($serializedArray = $cache->load()) { $sitemapTree->unserialize($serializedArray); } elseif (is_file($this->configFile)) { $sitemapTree = $this->expandChildNodes($parent, Yaml::load($this->configFile)); $cache->cacheSerializedArray($sitemapTree->serialize()); } return $sitemapTree; }
/** * Converts a serialized array back into a SitemapTree object */ public function unserialize($importArray = array()) { foreach ($importArray as $nodeArray) { if (isset($nodeArray['name']) && isset($nodeArray['href'])) { $node = new SitemapTree($nodeArray['name']); $node->setHref($nodeArray['href']); if (isset($nodeArray['nodes']) && is_array($nodeArray['nodes'])) { $node->unserialize($nodeArray['nodes']); } $this->addNode($node); } } }