1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* AdminLte Theme for hiqdev/yii2-thememanager |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/yii2-theme-adminlte |
6
|
|
|
* @package yii2-theme-adminlte |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hiqdev\themes\adminlte\models; |
12
|
|
|
|
13
|
|
|
use Yii; |
14
|
|
|
|
15
|
|
|
class Settings extends \hiqdev\thememanager\models\Settings |
16
|
|
|
{ |
17
|
|
|
protected $_defaults = [ |
18
|
|
|
'skin' => 'skin-blue', |
19
|
|
|
]; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Can have values: fixed, layout-boxed. |
23
|
|
|
* |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
public $layout; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Can have values: skin-blue, skin-yellow, skin-purple, skin-green, skin-red, skin-black, skin-ebony. |
30
|
|
|
* |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
public $skin; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Can have value: table-condensed, blank. |
37
|
|
|
* |
38
|
|
|
* @var bool |
39
|
|
|
*/ |
40
|
|
|
public $table_condensed; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var bool |
44
|
|
|
*/ |
45
|
|
|
public $collapsed_sidebar; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var string |
49
|
|
|
*/ |
50
|
|
|
public $filterOrientation; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return array |
54
|
|
|
*/ |
55
|
|
|
public function rules() |
56
|
|
|
{ |
57
|
|
|
return [ |
|
|
|
|
58
|
|
|
[['layout', 'skin', 'table_condensed', 'collapsed_sidebar'], 'safe'], |
59
|
|
|
[['filterOrientation'], 'in', 'range' => [self::ORIENTATION_VERTICAL, self::ORIENTATION_HORIZONTAL]], |
60
|
|
|
]; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return array |
65
|
|
|
*/ |
66
|
|
|
public function orientationOptions() |
67
|
|
|
{ |
68
|
|
|
return [ |
69
|
|
|
self::ORIENTATION_HORIZONTAL => Yii::t('adminlte', 'Horizontal'), |
70
|
|
|
self::ORIENTATION_VERTICAL => Yii::t('adminlte', 'Vertical'), |
71
|
|
|
]; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @return array |
76
|
|
|
*/ |
77
|
|
|
public function formLayoutData() |
78
|
|
|
{ |
79
|
|
|
return [ |
80
|
|
|
'none' => Yii::t('adminlte', 'Default layout'), |
81
|
|
|
'fixed' => Yii::t('adminlte', 'Fixed layout'), |
82
|
|
|
// working incorectly temporary disabled |
83
|
|
|
// 'layout-boxed' => Yii::t('adminlte', 'Boxed layout'), |
|
|
|
|
84
|
|
|
]; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return array |
89
|
|
|
*/ |
90
|
|
|
public function attributeLabels() |
91
|
|
|
{ |
92
|
|
|
return [ |
93
|
|
|
'verifyCode' => 'Verification Code', |
94
|
|
|
'table_condensed' => Yii::t('adminlte', 'Table Condensed'), |
95
|
|
|
'collapsed_sidebar' => Yii::t('adminlte', 'Collapsed Sidebar'), |
96
|
|
|
'filterOrientation' => Yii::t('adminlte', 'Search position'), |
97
|
|
|
]; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return array |
102
|
|
|
*/ |
103
|
|
|
public function skinSampleArray() |
104
|
|
|
{ |
105
|
|
|
return [ |
106
|
|
|
[ |
107
|
|
|
'attribute' => 'skin-red', |
108
|
|
|
'label' => Yii::t('adminlte', 'Red'), |
109
|
|
|
'color' => '#dd4b39', |
110
|
|
|
'bg' => 'bg-red', |
111
|
|
|
], |
112
|
|
|
[ |
113
|
|
|
'attribute' => 'skin-green', |
114
|
|
|
'label' => Yii::t('adminlte', 'Green'), |
115
|
|
|
'color' => '#00a65a', |
116
|
|
|
'bg' => 'bg-green', |
117
|
|
|
], |
118
|
|
|
[ |
119
|
|
|
'attribute' => 'skin-blue', |
120
|
|
|
'label' => Yii::t('adminlte', 'Blue'), |
121
|
|
|
'color' => '#3c8dbc', |
122
|
|
|
'bg' => 'bg-light-blue', |
123
|
|
|
], |
124
|
|
|
[ |
125
|
|
|
'attribute' => 'skin-purple', |
126
|
|
|
'label' => Yii::t('adminlte', 'Purple'), |
127
|
|
|
'color' => '#605ca8', |
128
|
|
|
'bg' => 'bg-purple', |
129
|
|
|
], |
130
|
|
|
[ |
131
|
|
|
'attribute' => 'skin-yellow', |
132
|
|
|
'label' => Yii::t('adminlte', 'Yellow'), |
133
|
|
|
'color' => '#f39c12', |
134
|
|
|
'bg' => 'bg-yellow', |
135
|
|
|
], |
136
|
|
|
/*[ |
|
|
|
|
137
|
|
|
'attribute' => 'skin-black', |
138
|
|
|
'label' => Yii::t('adminlte', 'Black'), |
139
|
|
|
'color' => '#fff', |
140
|
|
|
'bg' => 'bg-black', |
141
|
|
|
], |
142
|
|
|
[ |
143
|
|
|
'attribute' => 'skin-ebony', |
144
|
|
|
'label' => Yii::t('adminlte', 'Ebony'), |
145
|
|
|
'color' => '#fff', |
146
|
|
|
'bg' => 'bg-black', |
147
|
|
|
],*/ |
148
|
|
|
]; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Provides css class by given attribute name and value. |
153
|
|
|
* |
154
|
|
|
* @param $name string attribute name |
155
|
|
|
* @param $value boolean|string attribute value |
156
|
|
|
* |
157
|
|
|
* @return string css class |
158
|
|
|
*/ |
159
|
|
|
public static function cssClassProvider($name, $value) |
160
|
|
|
{ |
161
|
|
|
switch ($name) { |
162
|
|
|
case 'table_condensed': |
163
|
|
|
return $value ? 'table-condensed' : ''; |
164
|
|
|
break; |
|
|
|
|
165
|
|
|
case 'collapsed_sidebar': |
166
|
|
|
return $value ? 'sidebar-collapse' : ''; |
167
|
|
|
break; |
|
|
|
|
168
|
|
|
default: |
169
|
|
|
return parent::cssClassProvider($name, $value); |
170
|
|
|
} |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
public function getBodyClasses() |
174
|
|
|
{ |
175
|
|
|
return $this->getCssClasses(['layout', 'skin', 'table_condensed', 'collapsed_sidebar']); |
176
|
|
|
} |
177
|
|
|
} |
178
|
|
|
|
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.
Let’s take a look at an example:
Our function
my_function
expects aPost
object, and outputs the author of the post. The base classPost
returns a simple string and outputting a simple string will work just fine. However, the child classBlogPost
which is a sub-type ofPost
instead decided to return anobject
, and is therefore violating the SOLID principles. If aBlogPost
were passed tomy_function
, PHP would not complain, but ultimately fail when executing thestrtoupper
call in its body.