|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* WebHemi. |
|
4
|
|
|
* |
|
5
|
|
|
* PHP version 7.1 |
|
6
|
|
|
* |
|
7
|
|
|
* @copyright 2012 - 2017 Gixx-web (http://www.gixx-web.com) |
|
8
|
|
|
* @license https://opensource.org/licenses/MIT The MIT License (MIT) |
|
9
|
|
|
* |
|
10
|
|
|
* @link http://www.gixx-web.com |
|
11
|
|
|
*/ |
|
12
|
|
|
declare(strict_types = 1); |
|
13
|
|
|
|
|
14
|
|
|
namespace WebHemi\Renderer\Helper; |
|
15
|
|
|
|
|
16
|
|
|
use WebHemi\DateTime; |
|
17
|
|
|
use WebHemi\Environment\ServiceInterface as EnvironmentInterface; |
|
18
|
|
|
use WebHemi\Renderer\HelperInterface; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Class GetDatesHelper |
|
22
|
|
|
*/ |
|
23
|
|
|
class GetDatesHelper implements HelperInterface |
|
24
|
|
|
{ |
|
25
|
|
|
/** @var EnvironmentInterface */ |
|
26
|
|
|
private $environmentManager; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* GetTagsHelper constructor. |
|
30
|
|
|
* |
|
31
|
|
|
* @param EnvironmentInterface $environmentManager |
|
32
|
|
|
*/ |
|
33
|
|
|
public function __construct(EnvironmentInterface $environmentManager) |
|
34
|
|
|
{ |
|
35
|
|
|
$this->environmentManager = $environmentManager; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Should return the name of the helper. |
|
40
|
|
|
* |
|
41
|
|
|
* @return string |
|
42
|
|
|
*/ |
|
43
|
|
|
public static function getName() : string |
|
44
|
|
|
{ |
|
45
|
|
|
return 'getDates'; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Should return the name of the helper. |
|
50
|
|
|
* |
|
51
|
|
|
* @return string |
|
52
|
|
|
*/ |
|
53
|
|
|
public static function getDefinition() : string |
|
54
|
|
|
{ |
|
55
|
|
|
return '{{ getDates(order_by, limit) }}'; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Gets helper options for the render. |
|
60
|
|
|
* |
|
61
|
|
|
* @return array |
|
62
|
|
|
* @codeCoverageIgnore - empty array |
|
63
|
|
|
*/ |
|
64
|
|
|
public static function getOptions() : array |
|
65
|
|
|
{ |
|
66
|
|
|
return []; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Should return a description text. |
|
71
|
|
|
* |
|
72
|
|
|
* @return string |
|
73
|
|
|
*/ |
|
74
|
|
|
public static function getDescription() : string |
|
75
|
|
|
{ |
|
76
|
|
|
return 'Returns the archive dates for the current application.'; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* A renderer helper should be called with its name. |
|
81
|
|
|
* |
|
82
|
|
|
* @return array |
|
83
|
|
|
*/ |
|
84
|
|
|
public function __invoke() : array |
|
85
|
|
|
{ |
|
86
|
|
|
/* TODO: tbd */ |
|
87
|
|
|
$dates = [ |
|
88
|
|
|
new DateTime('now'), |
|
89
|
|
|
new DateTime(mktime(12, 11, 10, 9, 18, 2017)), |
|
90
|
|
|
new DateTime(mktime(12, 11, 10, 8, 20, 2017)), |
|
91
|
|
|
new DateTime(mktime(12, 11, 10, 3, 15, 2016)), |
|
92
|
|
|
]; |
|
93
|
|
|
|
|
94
|
|
|
$archives = []; |
|
95
|
|
|
|
|
96
|
|
|
/** @var DateTime $date */ |
|
97
|
|
|
foreach ($dates as $date) { |
|
98
|
|
|
$archives[] = [ |
|
99
|
|
|
'url' => $date->format('Y-m'), |
|
100
|
|
|
'title' => $date->format('Y4B'), |
|
101
|
|
|
'total' => 0, |
|
102
|
|
|
'new' => 0 |
|
103
|
|
|
]; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
return $archives; |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|