Completed
Push — master ( da2f6e...d3b8cb )
by Kamil
20:06
created

SitemapController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 35
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A showAction() 0 9 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Bundle\CoreBundle\Controller;
13
14
use Sylius\Bundle\CoreBundle\Sitemap\Renderer\SitemapRendererInterface;
15
use Sylius\Bundle\CoreBundle\Sitemap\Builder\SitemapBuilderInterface;
16
use Symfony\Component\HttpFoundation\Response;
17
18
/**
19
 * @author Arkadiusz Krakowiak <[email protected]>
20
 */
21
class SitemapController
22
{
23
    /**
24
     * @var SitemapRendererInterface
25
     */
26
    private $sitemapRenderer;
27
28
    /**
29
     * @var SitemapBuilderInterface
30
     */
31
    private $sitemapBuilder;
32
33
    /**
34
     * @param SitemapRendererInterface $sitemapRenderer
35
     * @param SitemapBuilderInterface $sitemapBuilder
36
     */
37
    public function __construct(SitemapRendererInterface $sitemapRenderer, SitemapBuilderInterface $sitemapBuilder)
38
    {
39
        $this->sitemapRenderer = $sitemapRenderer;
40
        $this->sitemapBuilder = $sitemapBuilder;
41
    }
42
43
    /**
44
     * @return Response
45
     */
46
    public function showAction()
47
    {
48
        $sitemap = $this->sitemapBuilder->build();
49
50
        $response = new Response($this->sitemapRenderer->render($sitemap));
51
        $response->headers->set('Content-Type', 'application/xml');
52
53
        return $response;
54
    }
55
}
56