@@ 189-203 (lines=15) @@ | ||
186 | * @param string $name |
|
187 | * @return mixed|null|string |
|
188 | */ |
|
189 | public function getMeta($name) |
|
190 | { |
|
191 | /* @var $model \common\models\MediaMeta */ |
|
192 | $model = MediaMeta::findOne(['name' => $name, 'media_id' => $this->id]); |
|
193 | ||
194 | if ($model) { |
|
195 | if (Json::isJson($model->value)) { |
|
196 | return Json::decode($model->value); |
|
197 | } |
|
198 | ||
199 | return $model->value; |
|
200 | } |
|
201 | ||
202 | return null; |
|
203 | } |
|
204 | ||
205 | /** |
|
206 | * Add new meta data for current media. |
@@ 72-86 (lines=15) @@ | ||
69 | * @param string $name |
|
70 | * @return string|array|boolean |
|
71 | */ |
|
72 | public static function get($name) |
|
73 | { |
|
74 | /* @var $model \common\models\Option */ |
|
75 | $model = static::findOne(['name' => $name]); |
|
76 | ||
77 | if ($model) { |
|
78 | if (Json::isJson($model->value)) { |
|
79 | return Json::decode($model->value); |
|
80 | } |
|
81 | ||
82 | return $model->value; |
|
83 | } |
|
84 | ||
85 | return null; |
|
86 | } |
|
87 | ||
88 | /** |
|
89 | * Add new option, required name and value. |
@@ 236-250 (lines=15) @@ | ||
233 | * @param string $name |
|
234 | * @return mixed|null |
|
235 | */ |
|
236 | public function getMeta($name) |
|
237 | { |
|
238 | /* @var $model \common\models\PostMeta */ |
|
239 | $model = PostMeta::findOne(['name' => $name, 'post_id' => $this->id]); |
|
240 | ||
241 | if ($model) { |
|
242 | if (Json::isJson($model->value)) { |
|
243 | return Json::decode($model->value); |
|
244 | } |
|
245 | ||
246 | return $model->value; |
|
247 | } |
|
248 | ||
249 | return null; |
|
250 | } |
|
251 | ||
252 | /** |
|
253 | * Add new meta data for current post. |