1 | <?php |
||
12 | class Settings extends Component |
||
13 | { |
||
14 | /** |
||
15 | * @event SettingsEvent an event that is triggered before execute command. |
||
16 | */ |
||
17 | const EVENT_BEFORE_EXECUTE = 'beforeExecute'; |
||
18 | |||
19 | /* |
||
20 | * @var array The settings cache |
||
21 | */ |
||
22 | private $_data = []; |
||
23 | |||
24 | /** |
||
25 | * @var string Name of the table where configurations will be stored |
||
26 | */ |
||
27 | public $tableName = '{{%setting}}'; |
||
28 | |||
29 | /** |
||
30 | * @var string Name of column where keys will be stored |
||
31 | */ |
||
32 | public $keyColumnName = 'key'; |
||
33 | |||
34 | /** |
||
35 | * @var string Name of column where values will be stored |
||
36 | */ |
||
37 | public $valueColumnName = 'value'; |
||
38 | |||
39 | /** |
||
40 | * @return Connection the DB connection instance |
||
41 | */ |
||
42 | 2 | protected function getDb() |
|
46 | |||
47 | /** |
||
48 | * Whether the setting exists in the database |
||
49 | * @param string $name the setting name |
||
50 | * @return bool |
||
51 | */ |
||
52 | 2 | protected function exists($name) |
|
69 | |||
70 | /** |
||
71 | * Returns setting value from database |
||
72 | * @param string $name setting name |
||
73 | * @return mixed $defaultValue |
||
74 | */ |
||
75 | 2 | public function get($name, $defaultValue = null) |
|
105 | |||
106 | /** |
||
107 | * Store setting value to database |
||
108 | * @param string $name |
||
109 | * @param mixed $value |
||
110 | */ |
||
111 | 2 | public function set($name, $value) |
|
139 | |||
140 | /** |
||
141 | * Retrieves all setting stored in database |
||
142 | * @return array |
||
143 | */ |
||
144 | 1 | public function all() |
|
165 | |||
166 | /** |
||
167 | * Store all settings in database |
||
168 | * @param array $names |
||
169 | */ |
||
170 | 1 | public function save($names) |
|
176 | |||
177 | /** |
||
178 | * Remove specified setting |
||
179 | * @param array|string $name |
||
180 | */ |
||
181 | 1 | public function remove($name) |
|
198 | |||
199 | /** |
||
200 | * Removes all settings |
||
201 | */ |
||
202 | 1 | public function removeAll() |
|
214 | |||
215 | /** |
||
216 | * Creates query to find settings value |
||
217 | * @param string $name |
||
218 | * @return \yii\db\Query |
||
219 | */ |
||
220 | 2 | protected function createQuery($name = null) |
|
232 | |||
233 | /** |
||
234 | * This method is called at the before execute db command |
||
235 | * @return yii\base\Event |
||
236 | */ |
||
237 | 2 | protected function beforeExecute() |
|
243 | |||
244 | /** |
||
245 | * Builds the unique cache key |
||
246 | * @param string $name |
||
247 | * @param array $data |
||
248 | * @return void |
||
249 | */ |
||
250 | 2 | protected function buildCacheKey($name, $data) |
|
257 | |||
258 | } |
||
259 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.