Completed
Push — refactoring-session ( a6dec9 )
by Kamil
06:43
created

ChartController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Sylius\Bundle\AdminBundle\Controller\Dashboard;
6
7
use Sylius\Component\Core\Dashboard\SalesDataProviderInterface;
8
use Sylius\Component\Core\Model\ChannelInterface;
9
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
10
use Symfony\Component\HttpFoundation\Response;
11
12
final class ChartController
13
{
14
    /**
15
     * @var EngineInterface
16
     */
17
    private $templatingEngine;
18
19
    /**
20
     * @var SalesDataProviderInterface
21
     */
22
    private $salesDataProvider;
23
24
    public function __construct(
25
        EngineInterface $templatingEngine,
26
        SalesDataProviderInterface $salesDataProvider
27
    ) {
28
        $this->templatingEngine = $templatingEngine;
29
        $this->salesDataProvider = $salesDataProvider;
30
    }
31
32
    public function __invoke(ChannelInterface $channel): Response
33
    {
34
        return $this->templatingEngine->renderResponse('@SyliusAdmin/Dashboard/Chart/_template.html.twig', [
35
            'sales_summary' => $this->salesDataProvider->getLastYearSalesSummary($channel),
36
        ]);
37
    }
38
}
39