public function testUseSchemaValidation() { $this->markTestSkipped('Skipped because it fetches XSD from web'); return; $nav = clone $this->_nav2; $this->_helper->setUseSitemapValidators(false); $this->_helper->setUseSchemaValidation(true); $nav->addPage(array('label' => 'Invalid', 'uri' => 'http://w.')); try { $this->_helper->render($nav); } catch (View\Exception\ExceptionInterface $e) { $expected = sprintf('Sitemap is invalid according to XML Schema at "%s"', \Zend\View\Helper\Navigation\Sitemap::SITEMAP_XSD); $actual = $e->getMessage(); $this->assertEquals($expected, $actual); return; } $this->fail('A Zend\\View\\Exception\\InvalidArgumentException was not thrown when using Schema validation'); }
/** * Renders helper * * @param AbstractContainer $container * [optional] container to render. * Default is to render the container registered in the helper. * @return string */ public function render($container = null) { Pi::service('log')->start('sitemap'); // Try to load from cache if ($this->cache) { $cacheKey = $this->cache->key . '-sp'; $content = $this->cache->storage->getItem($cacheKey); if (null !== $content) { if (Pi::service()->hasService('log')) { Pi::service('log')->info('Sitemap is loaded from cache.'); } return $content; } } // Generate if no cache available $content = parent::render($container); // Save to cache if ($this->cache) { $this->cache->storage->setItem($cacheKey, $content); } Pi::service('log')->end('sitemap'); return $content; }
/** * Render a site map file * * @param Navigation\Sitemap $helper * @param string $nameFile * @return string */ public function renderSiteMap(Navigation\Sitemap $helper, $nameFile) { $data = $helper->render(); $path = $this->getPath() . '/' . $nameFile; file_put_contents($path, $data); return $path; }