1
|
|
|
<?php namespace Anomaly\Streams\Platform\Ui\Table\Command; |
2
|
|
|
|
3
|
|
|
use Anomaly\Streams\Platform\Ui\Table\Component\Action\Command\BuildActions; |
4
|
|
|
use Anomaly\Streams\Platform\Ui\Table\Component\Action\Command\SetActiveAction; |
5
|
|
|
use Anomaly\Streams\Platform\Ui\Table\Component\Filter\Command\BuildFilters; |
6
|
|
|
use Anomaly\Streams\Platform\Ui\Table\Component\Filter\Command\SetActiveFilters; |
7
|
|
|
use Anomaly\Streams\Platform\Ui\Table\Component\Header\Command\BuildHeaders; |
8
|
|
|
use Anomaly\Streams\Platform\Ui\Table\Component\Row\Command\BuildRows; |
9
|
|
|
use Anomaly\Streams\Platform\Ui\Table\Component\View\Command\BuildViews; |
10
|
|
|
use Anomaly\Streams\Platform\Ui\Table\Component\View\Command\SetActiveView; |
11
|
|
|
use Anomaly\Streams\Platform\Ui\Table\TableBuilder; |
12
|
|
|
use Illuminate\Foundation\Bus\DispatchesJobs; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class BuildTable |
16
|
|
|
* |
17
|
|
|
* @link http://pyrocms.com/ |
18
|
|
|
* @author PyroCMS, Inc. <[email protected]> |
19
|
|
|
* @author Ryan Thompson <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
class BuildTable |
22
|
|
|
{ |
23
|
|
|
|
24
|
|
|
use DispatchesJobs; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* The table builder. |
28
|
|
|
* |
29
|
|
|
* @var TableBuilder |
30
|
|
|
*/ |
31
|
|
|
protected $builder; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Create a new BuildTableColumnsCommand instance. |
35
|
|
|
* |
36
|
|
|
* @param TableBuilder $builder |
37
|
|
|
*/ |
38
|
|
|
public function __construct(TableBuilder $builder) |
39
|
|
|
{ |
40
|
|
|
$this->builder = $builder; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Handle the command. |
45
|
|
|
*/ |
46
|
|
|
public function handle() |
47
|
|
|
{ |
48
|
|
|
/* |
49
|
|
|
* Resolve and set the table model and stream. |
50
|
|
|
*/ |
51
|
|
|
$this->dispatch(new SetTableModel($this->builder)); |
52
|
|
|
$this->dispatch(new SetTableStream($this->builder)); |
53
|
|
|
$this->dispatch(new SetDefaultParameters($this->builder)); |
54
|
|
|
$this->dispatch(new SetRepository($this->builder)); |
55
|
|
|
|
56
|
|
|
/* |
57
|
|
|
* Build table views and mark active. |
58
|
|
|
*/ |
59
|
|
|
$this->dispatch(new BuildViews($this->builder)); |
60
|
|
|
$this->dispatch(new SetActiveView($this->builder)); |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Set the table options going forward. |
64
|
|
|
*/ |
65
|
|
|
$this->dispatch(new SetTableOptions($this->builder)); |
66
|
|
|
$this->dispatch(new SetDefaultOptions($this->builder)); |
67
|
|
|
$this->dispatch(new SaveTableState($this->builder)); |
68
|
|
|
|
69
|
|
|
/* |
70
|
|
|
* Before we go any further, authorize the request. |
71
|
|
|
*/ |
72
|
|
|
$this->dispatch(new AuthorizeTable($this->builder)); |
73
|
|
|
|
74
|
|
|
/* |
75
|
|
|
* Build table filters and flag active. |
76
|
|
|
*/ |
77
|
|
|
$this->dispatch(new BuildFilters($this->builder)); |
78
|
|
|
$this->dispatch(new SetActiveFilters($this->builder)); |
79
|
|
|
|
80
|
|
|
/* |
81
|
|
|
* Build table actions and flag active. |
82
|
|
|
*/ |
83
|
|
|
$this->dispatch(new BuildActions($this->builder)); |
84
|
|
|
$this->dispatch(new SetActiveAction($this->builder)); |
85
|
|
|
|
86
|
|
|
/* |
87
|
|
|
* Build table headers. |
88
|
|
|
*/ |
89
|
|
|
$this->dispatch(new BuildHeaders($this->builder)); |
90
|
|
|
$this->dispatch(new EagerLoadRelations($this->builder)); |
91
|
|
|
|
92
|
|
|
/* |
93
|
|
|
* Get table entries. |
94
|
|
|
*/ |
95
|
|
|
$this->dispatch(new GetTableEntries($this->builder)); |
96
|
|
|
|
97
|
|
|
/* |
98
|
|
|
* Lastly table rows. |
99
|
|
|
*/ |
100
|
|
|
$this->dispatch(new BuildRows($this->builder)); |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|