File: D:/HostingSpaces/SBogers10/ijzerenman.komma.pro/app/Custom/Sitemap/SitemapService.php
<?php
namespace Komma\Sitemap;
/**
* Short description for the file.
*
* @author Tim Van Samang <timvansamang@komma.pro>
* @copyright (c) 2012-2015, Komma Mediadesign
*/
use Carbon\Carbon;
use Komma\Routes\RouteService;
use Roumen\Sitemap\Sitemap;
class SitemapService
{
private $routeService;
public function __construct(RouteService $routeService)
{
$this->routeService = $routeService;
}
/***
* This method will generate the sitemap based on the routes table
* It will collect the routes based on the given groups array.
* Then it will build the sitemap grouped by the linked id
*
* @param array $groups , which routes we want in the sitemap
* @param float $weight_from / the minimum weight of the sitemap itens
* @return Sitemap object
*/
public function getSitemap(
$groups = ['pages', 'categories', 'products'],
$weight_from = 0.1,
$homePage = true,
$translations = true)
{
//Create the sitemap class
$sitemap = \App::make('sitemap');
//Is the homepage variale set
if ($homePage) {
// Ad the home page on road / to the sitemap
$sitemap->add(
\URL::to('/'),
'2012-08-25T20:10:00+02:00',
'1.0',
'monthly',
[], 'Home'
);
}
$refresh = 'monthly';
//Loop trough the routes based on the given parameters
foreach ($this->routeService->getSitemapRoutes($groups, $weight_from) as $type => $route) {
$sitemap->add(\URL::to($route['route']), Carbon::now(), $route['weight'], $refresh, [], $route['name']);
}
return $sitemap;
}
}