Conditions | 3 |
Paths | 4 |
Total Lines | 14 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | public function saveMeta(Event $event) |
||
22 | { |
||
23 | /** @var Article $model */ |
||
24 | $model = $event->sender; |
||
25 | |||
26 | $meta = ArticleMetaFactory::findByArticleId($model->id); |
||
27 | if (!$meta) { |
||
|
|||
28 | $meta = ArticleMetaFactory::create($model->id, $model->content); |
||
29 | } else { |
||
30 | $meta->content = $model->content; |
||
31 | } |
||
32 | if (!$meta->save()) { |
||
33 | Yii::error($meta->getErrors(), __METHOD__); |
||
34 | throw new \Exception('Unable to save article meta'); |
||
35 | } |
||
49 |