@@ 78-94 (lines=17) @@ | ||
75 | * |
|
76 | * @return XML sitemap |
|
77 | */ |
|
78 | public function generateSitemap() |
|
79 | { |
|
80 | $sitemapXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n"; |
|
81 | ||
82 | $repository = $this->em->getRepository('WebCMS\Entity\Page'); |
|
83 | $pages = $repository->findAll(); |
|
84 | ||
85 | foreach ($pages as $page) { |
|
86 | if ($page->getParent() !== null && $page->getVisible()) { |
|
87 | $sitemapXml .= "<url>\n\t<loc>".$this->getSitemapLink($page)."</loc>\n</url>\n"; |
|
88 | } |
|
89 | } |
|
90 | ||
91 | $sitemapXml .= '</urlset>'; |
|
92 | ||
93 | file_put_contents('./sitemap.xml', $sitemapXml); |
|
94 | } |
|
95 | ||
96 | /** |
|
97 | * Get single sitemap link url address. |
@@ 277-293 (lines=17) @@ | ||
274 | } |
|
275 | } |
|
276 | ||
277 | public function generateSitemap() |
|
278 | { |
|
279 | $sitemapXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n"; |
|
280 | ||
281 | $repository = $this->em->getRepository('WebCMS\Entity\Page'); |
|
282 | $pages = $repository->findAll(); |
|
283 | ||
284 | foreach ($pages as $page) { |
|
285 | if ($page->getParent() !== null) { |
|
286 | $sitemapXml .= "<url>\n\t<loc>".$this->getSitemapLink($page)."</loc>\n</url>\n"; |
|
287 | } |
|
288 | } |
|
289 | ||
290 | $sitemapXml .= '</urlset>'; |
|
291 | ||
292 | file_put_contents('./sitemap.xml', $sitemapXml); |
|
293 | } |
|
294 | ||
295 | private function getSitemapLink($page) |
|
296 | { |