1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Rudolf\Component\Plugins; |
4
|
|
|
|
5
|
|
|
use Rudolf\Component\Hooks\Filter; |
6
|
|
|
use Rudolf\Component\Html\Foot; |
7
|
|
|
use Rudolf\Component\Html\Head; |
8
|
|
|
|
9
|
|
|
class DomPlugins |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @var Head |
13
|
|
|
*/ |
14
|
|
|
private $head; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var Foot |
18
|
|
|
*/ |
19
|
|
|
private $foot; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* DomPlugins constructor. |
23
|
|
|
* |
24
|
|
|
* @param Head $head |
25
|
|
|
* @param Foot $foot |
26
|
|
|
*/ |
27
|
|
|
public function __construct(Head $head, Foot $foot) |
28
|
|
|
{ |
29
|
|
|
$this->head = $head; |
30
|
|
|
$this->foot = $foot; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
View Code Duplication |
public function front() |
|
|
|
|
34
|
|
|
{ |
35
|
|
|
if (Filter::isHas('head_stylesheets')) { |
36
|
|
|
$head_stylesheets = Filter::apply('head_stylesheets', $this->head->getStylesheetsArray()); |
37
|
|
|
$this->head->setStylesheetsArray($head_stylesheets); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
if (Filter::isHas('head_scripts')) { |
41
|
|
|
$head_scripts = Filter::apply('head_scripts', $this->head->getScriptsArray()); |
42
|
|
|
$this->head->setScriptsArray($head_scripts); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
if (Filter::isHas('foot_scripts')) { |
46
|
|
|
$foot_scripts = Filter::apply('foot_scripts', $this->foot->getScriptsArray()); |
47
|
|
|
$this->foot->setScriptsArray($foot_scripts); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
if (Filter::isHas('head_before')) { |
51
|
|
|
$head_before = Filter::apply('head_before', $this->head->getBeforeArray()); |
52
|
|
|
$this->head->setBeforeArray($head_before); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
if (Filter::isHas('head_after')) { |
56
|
|
|
$head_after = Filter::apply('head_after', $this->head->getAfterArray()); |
57
|
|
|
$this->head->setAfterArray($head_after); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
if (Filter::isHas('foot_before')) { |
61
|
|
|
$foot_before = Filter::apply('foot_before', $this->foot->getBeforeArray()); |
62
|
|
|
$this->foot->setBeforeArray($foot_before); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
if (Filter::isHas('foot_after')) { |
66
|
|
|
$foot_after = Filter::apply('foot_after', $this->foot->getAfterArray()); |
67
|
|
|
$this->foot->setAfterArray($foot_after); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
71
|
|
View Code Duplication |
public function admin() |
|
|
|
|
72
|
|
|
{ |
73
|
|
|
if (Filter::isHas('admin_head_stylesheets')) { |
74
|
|
|
$head_stylesheets = Filter::apply('admin_head_stylesheets', $this->head->getStylesheetsArray()); |
75
|
|
|
$this->head->setStylesheetsArray($head_stylesheets); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
if (Filter::isHas('admin_head_scripts')) { |
79
|
|
|
$head_scripts = Filter::apply('admin_head_scripts', $this->head->getScriptsArray()); |
80
|
|
|
$this->head->setScriptsArray($head_scripts); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
if (Filter::isHas('admin_foot_scripts')) { |
84
|
|
|
$foot_scripts = Filter::apply('admin_foot_scripts', $this->foot->getScriptsArray()); |
85
|
|
|
$this->foot->setScriptsArray($foot_scripts); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
if (Filter::isHas('admin_head_before')) { |
89
|
|
|
$head_before = Filter::apply('admin_head_before', $this->head->getBeforeArray()); |
90
|
|
|
$this->head->setBeforeArray($head_before); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
if (Filter::isHas('admin_head_after')) { |
94
|
|
|
$head_after = Filter::apply('admin_head_after', $this->head->getAfterArray()); |
95
|
|
|
$this->head->setAfterArray($head_after); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
if (Filter::isHas('admin_foot_before')) { |
99
|
|
|
$foot_before = Filter::apply('admin_foot_before', $this->foot->getBeforeArray()); |
100
|
|
|
$this->foot->setBeforeArray($foot_before); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
if (Filter::isHas('admin_foot_after')) { |
104
|
|
|
$foot_after = Filter::apply('admin_foot_after', $this->foot->getAfterArray()); |
105
|
|
|
$this->foot->setAfterArray($foot_after); |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
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.