| @@ 648-660 (lines=13) @@ | ||
| 645 | * |
|
| 646 | * @throws \Exception |
|
| 647 | */ |
|
| 648 | public function saveSitemapItem($slug, $postValues) |
|
| 649 | { |
|
| 650 | $sitemapObject = $this->createSitemapItemFromPostValues($postValues); |
|
| 651 | ||
| 652 | $sitemap = $this->repository->sitemap; |
|
| 653 | foreach ($sitemap as $key => $sitemapItem) { |
|
| 654 | if ($sitemapItem->slug == $slug) { |
|
| 655 | $sitemap[$key] = $sitemapObject; |
|
| 656 | } |
|
| 657 | } |
|
| 658 | $this->repository->sitemap = $sitemap; |
|
| 659 | $this->save(); |
|
| 660 | } |
|
| 661 | ||
| 662 | /** |
|
| 663 | * Delete a sitemap item by its slug |
|
| @@ 669-680 (lines=12) @@ | ||
| 666 | * |
|
| 667 | * @throws \Exception |
|
| 668 | */ |
|
| 669 | public function deleteSitemapItemBySlug($slug) |
|
| 670 | { |
|
| 671 | $sitemap = $this->repository->sitemap; |
|
| 672 | foreach ($sitemap as $key => $sitemapItem) { |
|
| 673 | if ($sitemapItem->slug == $slug) { |
|
| 674 | unset($sitemap[$key]); |
|
| 675 | } |
|
| 676 | } |
|
| 677 | $sitemap = array_values($sitemap); |
|
| 678 | $this->repository->sitemap = $sitemap; |
|
| 679 | $this->save(); |
|
| 680 | } |
|
| 681 | ||
| 682 | /** |
|
| 683 | * Create a sitemap item from post values |
|