|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Odiseo\SyliusReportPlugin\Model; |
|
6
|
|
|
|
|
7
|
|
|
use DateTime; |
|
8
|
|
|
use Odiseo\SyliusReportPlugin\DataFetcher\DefaultDataFetchers; |
|
9
|
|
|
use Odiseo\SyliusReportPlugin\DataFetcher\TimePeriodDataFetcher; |
|
10
|
|
|
use Odiseo\SyliusReportPlugin\Renderer\DefaultRenderers; |
|
11
|
|
|
use Sylius\Component\Resource\Model\TimestampableTrait; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @author Łukasz Chruściel <[email protected]> |
|
15
|
|
|
* @author Mateusz Zalewski <[email protected]> |
|
16
|
|
|
* @author Diego D'amico <[email protected]> |
|
17
|
|
|
*/ |
|
18
|
|
|
class Report implements ReportInterface |
|
19
|
|
|
{ |
|
20
|
|
|
use TimestampableTrait; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var mixed |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $id; |
|
26
|
|
|
|
|
27
|
|
|
protected ?string $code = null; |
|
28
|
|
|
|
|
29
|
|
|
protected ?string $name = null; |
|
30
|
|
|
|
|
31
|
|
|
protected ?string $description = null; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Renderer name. |
|
35
|
|
|
*/ |
|
36
|
|
|
protected string $renderer = DefaultRenderers::TABLE; |
|
37
|
|
|
|
|
38
|
|
|
protected array $rendererConfiguration = []; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Data fetcher name. |
|
42
|
|
|
*/ |
|
43
|
|
|
protected string $dataFetcher = DefaultDataFetchers::USER_REGISTRATION; |
|
44
|
|
|
|
|
45
|
|
|
protected array $dataFetcherConfiguration = []; |
|
46
|
|
|
|
|
47
|
|
|
public function __construct() |
|
48
|
|
|
{ |
|
49
|
|
|
$this->createdAt = new DateTime(); |
|
50
|
|
|
$this->dataFetcherConfiguration = [ |
|
51
|
|
|
'timePeriod' => [ |
|
52
|
|
|
'start' => new DateTime('10 years'), |
|
53
|
|
|
'end' => new DateTime(), |
|
54
|
|
|
'period' => TimePeriodDataFetcher::PERIOD_MONTH |
|
55
|
|
|
] |
|
56
|
|
|
]; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* {@inheritdoc} |
|
61
|
|
|
*/ |
|
62
|
|
|
public function getId() |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->id; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function getCode(): ?string |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->code; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function setCode(?string $code): void |
|
73
|
|
|
{ |
|
74
|
|
|
$this->code = $code; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public function getName(): ?string |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->name; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function setName(?string $name): void |
|
83
|
|
|
{ |
|
84
|
|
|
$this->name = $name; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public function getDescription(): ?string |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->description; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function setDescription(?string $description): void |
|
93
|
|
|
{ |
|
94
|
|
|
$this->description = $description; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function getDataFetcher(): string |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->dataFetcher; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
public function setDataFetcher(string $dataFetcher): void |
|
103
|
|
|
{ |
|
104
|
|
|
$this->dataFetcher = $dataFetcher; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
public function getRenderer(): string |
|
108
|
|
|
{ |
|
109
|
|
|
return $this->renderer; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
public function setRenderer(string $renderer): void |
|
113
|
|
|
{ |
|
114
|
|
|
$this->renderer = $renderer; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
public function getDataFetcherConfiguration(): array |
|
118
|
|
|
{ |
|
119
|
|
|
return $this->dataFetcherConfiguration; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
public function setDataFetcherConfiguration(array $dataFetcherConfiguration): void |
|
123
|
|
|
{ |
|
124
|
|
|
$this->dataFetcherConfiguration = $dataFetcherConfiguration; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
public function getRendererConfiguration(): array |
|
128
|
|
|
{ |
|
129
|
|
|
return $this->rendererConfiguration; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
public function setRendererConfiguration(array $rendererConfiguration): void |
|
133
|
|
|
{ |
|
134
|
|
|
$this->rendererConfiguration = $rendererConfiguration; |
|
135
|
|
|
} |
|
136
|
|
|
} |
|
137
|
|
|
|