| @@ 472-484 (lines=13) @@ | ||
| 469 | * |
|
| 470 | * @throws \Exception |
|
| 471 | */ |
|
| 472 | public function saveSitemapItem($slug, $postValues) |
|
| 473 | { |
|
| 474 | $sitemapObject = $this->createSitemapItemFromPostValues($postValues); |
|
| 475 | ||
| 476 | $sitemap = $this->repository->sitemap; |
|
| 477 | foreach ($sitemap as $key => $sitemapItem) { |
|
| 478 | if ($sitemapItem->slug == $slug) { |
|
| 479 | $sitemap[$key] = $sitemapObject; |
|
| 480 | } |
|
| 481 | } |
|
| 482 | $this->repository->sitemap = $sitemap; |
|
| 483 | $this->save(); |
|
| 484 | } |
|
| 485 | ||
| 486 | /** |
|
| 487 | * Delete a sitemap item by its slug |
|
| @@ 493-504 (lines=12) @@ | ||
| 490 | * |
|
| 491 | * @throws \Exception |
|
| 492 | */ |
|
| 493 | public function deleteSitemapItemBySlug($slug) |
|
| 494 | { |
|
| 495 | $sitemap = $this->repository->sitemap; |
|
| 496 | foreach ($sitemap as $key => $sitemapItem) { |
|
| 497 | if ($sitemapItem->slug == $slug) { |
|
| 498 | unset($sitemap[$key]); |
|
| 499 | } |
|
| 500 | } |
|
| 501 | $sitemap = array_values($sitemap); |
|
| 502 | $this->repository->sitemap = $sitemap; |
|
| 503 | $this->save(); |
|
| 504 | } |
|
| 505 | ||
| 506 | /** |
|
| 507 | * Create a sitemap item from post values |
|