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\Component\Core\Dashboard; |
13
|
|
|
|
14
|
|
|
use Sylius\Component\Core\Model\ChannelInterface; |
15
|
|
|
use Sylius\Component\Core\Repository\CustomerRepositoryInterface; |
16
|
|
|
use Sylius\Component\Core\Repository\OrderRepositoryInterface; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @author Paweł Jędrzejewski <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
class DashboardStatisticsProvider implements DashboardStatisticsProviderInterface |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var OrderRepositoryInterface |
25
|
|
|
*/ |
26
|
|
|
private $orderRepository; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var CustomerRepositoryInterface |
30
|
|
|
*/ |
31
|
|
|
private $customerRepository; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param OrderRepositoryInterface $orderRepository |
35
|
|
|
* @param CustomerRepositoryInterface $customerRepository |
36
|
|
|
*/ |
37
|
|
|
public function __construct( |
38
|
|
|
OrderRepositoryInterface $orderRepository, |
39
|
|
|
CustomerRepositoryInterface $customerRepository |
40
|
|
|
) { |
41
|
|
|
$this->orderRepository = $orderRepository; |
42
|
|
|
$this->customerRepository = $customerRepository; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* {@inheritdoc} |
47
|
|
|
*/ |
48
|
|
|
public function getStatisticsForChannel(ChannelInterface $channel) |
49
|
|
|
{ |
50
|
|
|
return new DashboardStatistics( |
51
|
|
|
$this->orderRepository->getTotalSalesForChannel($channel), |
52
|
|
|
$this->orderRepository->countByChannel($channel), |
53
|
|
|
$this->customerRepository->count() |
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|