1
|
|
|
<?php namespace Anomaly\Streams\Platform\Ui\Table\Component\View\Command; |
2
|
|
|
|
3
|
|
|
use Anomaly\Streams\Platform\Ui\Table\Component\View\ViewHandler; |
4
|
|
|
use Anomaly\Streams\Platform\Ui\Table\TableBuilder; |
5
|
|
|
use Illuminate\Contracts\Container\Container; |
6
|
|
|
use Illuminate\Http\Request; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class SetActiveView |
10
|
|
|
* |
11
|
|
|
* @link http://pyrocms.com/ |
12
|
|
|
* @author PyroCMS, Inc. <[email protected]> |
13
|
|
|
* @author Ryan Thompson <[email protected]> |
14
|
|
|
*/ |
15
|
|
|
class SetActiveView |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* The table builder. |
20
|
|
|
* |
21
|
|
|
* @var TableBuilder |
22
|
|
|
*/ |
23
|
|
|
protected $builder; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Create a new BuildTableFiltersCommand instance. |
27
|
|
|
* |
28
|
|
|
* @param TableBuilder $builder |
29
|
|
|
*/ |
30
|
|
|
public function __construct(TableBuilder $builder) |
31
|
|
|
{ |
32
|
|
|
$this->builder = $builder; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Handle the command. |
37
|
|
|
* |
38
|
|
|
* @param Request $request |
39
|
|
|
* @param Container $container |
|
|
|
|
40
|
|
|
*/ |
41
|
|
|
public function handle(Request $request, ViewHandler $handler) |
42
|
|
|
{ |
43
|
|
|
$table = $this->builder->getTable(); |
44
|
|
|
$options = $table->getOptions(); |
45
|
|
|
$views = $table->getViews(); |
46
|
|
|
|
47
|
|
|
if ($views->active()) { |
48
|
|
|
return; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
View Code Duplication |
if ($view = $views->findBySlug($request->get($options->get('prefix') . 'view'))) { |
|
|
|
|
52
|
|
|
$view->setActive(true); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
if (!$view && $view = $views->first()) { |
56
|
|
|
$view->setActive(true); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
// Nothing to do. |
60
|
|
|
if (!$view) { |
61
|
|
|
return; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
// Set filters from active view. |
65
|
|
|
if (($filters = $view->getFilters()) !== null) { |
66
|
|
|
$this->builder->setFilters($filters); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
// Set columns from active view. |
70
|
|
|
if (($columns = $view->getColumns()) !== null) { |
71
|
|
|
$this->builder->setColumns($columns); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
// Set buttons from active view. |
75
|
|
|
if (($buttons = $view->getButtons()) !== null) { |
76
|
|
|
$this->builder->setButtons($buttons); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
// Set actions from active view. |
80
|
|
|
if (($actions = $view->getActions()) !== null) { |
81
|
|
|
$this->builder->setActions($actions); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
// Set options from active view. |
85
|
|
|
if (($options = $view->getOptions()) !== null) { |
86
|
|
|
$this->builder->setOptions($options); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
$handler->handle($this->builder, $view); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.