Completed
Push — master ( aba493...5356ed )
by Ruud
315:38 queued 305:00
created

SitemapBundle/Controller/SitemapController.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\SitemapBundle\Controller;
4
5
use Symfony\Component\Routing\Annotation\Route;
6
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
7
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8
use Symfony\Component\HttpFoundation\Request;
9
10
class SitemapController extends Controller
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Bundle\Framework...e\Controller\Controller has been deprecated with message: since Symfony 4.2, use "Symfony\Bundle\FrameworkBundle\Controller\AbstractController" instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
11
{
12
    /**
13
     * This will generate a sitemap for the specified locale.
14
     * Use the mode parameter to select in which mode the sitemap should be
15
     * generated. At this moment only XML is supported
16
     *
17
     * @Route("/sitemap-{locale}.{_format}", name="KunstmaanSitemapBundle_sitemap",
18
     *                                       requirements={"_format" = "xml"})
19
     * @Template("KunstmaanSitemapBundle:Sitemap:view.xml.twig")
20
     *
21
     * @param $locale
22
     *
23
     * @return array
24
     */
25
    public function sitemapAction($locale)
26
    {
27
        $nodeMenu = $this->get('kunstmaan_node.node_menu');
28
        $nodeMenu->setLocale($locale);
29
        $nodeMenu->setIncludeOffline(false);
30
        $nodeMenu->setIncludeHiddenFromNav(true);
31
        $nodeMenu->setCurrentNode(null);
32
33
        return array(
34
            'nodemenu' => $nodeMenu,
35
            'locale' => $locale,
36
        );
37
    }
38
39
    /**
40
     * This will generate a sitemap index file to define a sub sitemap for each
41
     * language. Info at:
42
     * https://support.google.com/webmasters/answer/75712?rd=1 Use the mode
43
     * parameter to select in which mode the sitemap should be generated. At
44
     * this moment only XML is supported
45
     *
46
     * @Route("/sitemap.{_format}", name="KunstmaanSitemapBundle_sitemapindex",
47
     *                              requirements={"_format" = "xml"})
48
     * @Template("KunstmaanSitemapBundle:SitemapIndex:view.xml.twig")
49
     *
50
     * @param Request $request
51
     *
52
     * @return array
53
     */
54
    public function sitemapIndexAction(Request $request)
55
    {
56
        $locales = $this->get('kunstmaan_admin.domain_configuration')
57
            ->getBackendLocales();
58
59
        return array(
60
            'locales' => $locales,
61
            'host' => $request->getSchemeAndHttpHost(),
62
        );
63
    }
64
}
65