|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Index traversing. |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace HDNET\Calendarize\ViewHelpers; |
|
8
|
|
|
|
|
9
|
|
|
use HDNET\Calendarize\Domain\Model\Index; |
|
10
|
|
|
use HDNET\Calendarize\Domain\Repository\IndexRepository; |
|
11
|
|
|
use TYPO3\CMS\Extbase\Persistence\QueryInterface; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Index traversing. |
|
15
|
|
|
* |
|
16
|
|
|
* == Examples == |
|
17
|
|
|
* |
|
18
|
|
|
* <code title="Traversing thru future and past occurings of the event"> |
|
19
|
|
|
* {namespace c=HDNET\Calendarize\ViewHelpers} |
|
20
|
|
|
* <f:for each="{c:indexTraversing(index:'{index}', future: 1, past: 0, limit: 10, sort: 'ASC', useIndexTime: 1)}" as="futureEvent"> |
|
21
|
|
|
* <f:debug>{futureEvent}</f:debug> |
|
22
|
|
|
* </f:for> |
|
23
|
|
|
* </code> |
|
24
|
|
|
*/ |
|
25
|
|
|
class IndexTraversingViewHelper extends AbstractViewHelper |
|
26
|
|
|
{ |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Init arguments |
|
30
|
|
|
*/ |
|
31
|
|
|
public function initializeArguments() |
|
32
|
|
|
{ |
|
33
|
|
|
parent::initializeArguments(); |
|
34
|
|
|
$this->registerArgument('index', Index::class, '', true); |
|
35
|
|
|
$this->registerArgument('future', 'bool', '', false, true); |
|
36
|
|
|
$this->registerArgument('past', 'bool', '', false, false); |
|
37
|
|
|
$this->registerArgument('limit', 'int', '', false, 100); |
|
38
|
|
|
$this->registerArgument('sort', 'string', '', false, QueryInterface::ORDER_ASCENDING); |
|
39
|
|
|
$this->registerArgument('useIndexTime', 'string', '', false, ''); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Render method. |
|
44
|
|
|
* |
|
45
|
|
|
* @return array |
|
46
|
|
|
*/ |
|
47
|
|
|
public function render() |
|
48
|
|
|
{ |
|
49
|
|
|
$indexRepository = $this->objectManager->get(IndexRepository::class); |
|
50
|
|
|
|
|
51
|
|
|
return $indexRepository->findByTraversing( |
|
52
|
|
|
$this->arguments['index'], |
|
53
|
|
|
$this->arguments['future'], |
|
54
|
|
|
$this->arguments['past'], |
|
55
|
|
|
(int)$this->arguments['limit'], |
|
56
|
|
|
$this->arguments['sort'], |
|
57
|
|
|
$this->arguments['useIndexTime'] |
|
58
|
|
|
); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|