|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace eXpansion\Framework\Core\Plugins\Gui; |
|
5
|
|
|
|
|
6
|
|
|
use eXpansion\Framework\Core\Helpers\Time; |
|
7
|
|
|
use eXpansion\Framework\Core\Model\Gui\Grid\DataCollectionFactory; |
|
8
|
|
|
use eXpansion\Framework\Core\Model\Gui\Grid\GridBuilder; |
|
9
|
|
|
use eXpansion\Framework\Core\Model\Gui\Grid\GridBuilderFactory; |
|
10
|
|
|
use eXpansion\Framework\Core\Model\Gui\ManialinkInterface; |
|
11
|
|
|
use FML\Controls\Frame; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class RecordsWindowFactory |
|
15
|
|
|
* |
|
16
|
|
|
* @package eXpansion\Bundle\LocalRecords\Plugins\Gui; |
|
17
|
|
|
* @author reaby |
|
18
|
|
|
*/ |
|
19
|
|
|
abstract class GridWindowFactory extends WindowFactory |
|
20
|
|
|
{ |
|
21
|
|
|
/** @var array */ |
|
22
|
|
|
protected $genericData = []; |
|
23
|
|
|
|
|
24
|
|
|
/** @var GridBuilderFactory */ |
|
25
|
|
|
protected $gridBuilderFactory; |
|
26
|
|
|
|
|
27
|
|
|
/** @var DataCollectionFactory */ |
|
28
|
|
|
protected $dataCollectionFactory; |
|
29
|
|
|
|
|
30
|
|
|
/** @var Time */ |
|
31
|
|
|
protected $timeFormatter; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var |
|
35
|
|
|
*/ |
|
36
|
|
|
protected $gridBuilder; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @inheritdoc |
|
40
|
|
|
*/ |
|
41
|
|
|
protected function createContent(ManialinkInterface $manialink) |
|
42
|
|
|
{ |
|
43
|
|
|
parent::createContent($manialink); |
|
44
|
|
|
$this->createGrid($manialink); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @param ManialinkInterface $manialink |
|
50
|
|
|
* @return mixed |
|
51
|
|
|
*/ |
|
52
|
|
|
abstract protected function createGrid(ManialinkInterface $manialink); |
|
53
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @inheritdoc |
|
57
|
|
|
*/ |
|
58
|
|
View Code Duplication |
protected function updateContent(ManialinkInterface $manialink) |
|
|
|
|
|
|
59
|
|
|
{ |
|
60
|
|
|
/** @var Frame $contentFrame */ |
|
61
|
|
|
$contentFrame = $manialink->getContentFrame(); |
|
62
|
|
|
$contentFrame->removeAllChildren(); |
|
63
|
|
|
|
|
64
|
|
|
$collection = $this->dataCollectionFactory->create($this->getData()); |
|
65
|
|
|
$collection->setPageSize(20); |
|
66
|
|
|
|
|
67
|
|
|
/** @var GridBuilder $gridBuilder */ |
|
68
|
|
|
$gridBuilder = $manialink->getData('grid'); |
|
69
|
|
|
$contentFrame->addChild($gridBuilder->build($contentFrame->getWidth(), $contentFrame->getHeight())); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @param array $data |
|
74
|
|
|
*/ |
|
75
|
|
|
public function setData($data) |
|
76
|
|
|
{ |
|
77
|
|
|
$this->genericData = $data; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @return array |
|
82
|
|
|
*/ |
|
83
|
|
|
public function getData() { |
|
84
|
|
|
return $this->genericData; |
|
85
|
|
|
} |
|
86
|
|
|
/** |
|
87
|
|
|
* @param GridBuilderFactory $gridBuilderFactory |
|
88
|
|
|
*/ |
|
89
|
|
|
public function setGridBuilderFactory($gridBuilderFactory) |
|
90
|
|
|
{ |
|
91
|
|
|
$this->gridBuilderFactory = $gridBuilderFactory; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @param DataCollectionFactory $dataCollectionFactory |
|
96
|
|
|
*/ |
|
97
|
|
|
public function setDataCollectionFactory($dataCollectionFactory) |
|
98
|
|
|
{ |
|
99
|
|
|
$this->dataCollectionFactory = $dataCollectionFactory; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @param Time $time |
|
104
|
|
|
*/ |
|
105
|
|
|
public function setTimerFormatter(Time $time) |
|
106
|
|
|
{ |
|
107
|
|
|
$this->timeFormatter = $time; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
|
|
111
|
|
|
} |
|
112
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.