Conditions | 3 |
Paths | 3 |
Total Lines | 24 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
23 | public function send(NotifiableInterface $recipient, NotificationInterface $notification) |
||
24 | { |
||
25 | $model = \Yii::createObject($this->model); |
||
|
|||
26 | |||
27 | if (!$model instanceof BaseActiveRecord) { |
||
28 | throw new InvalidConfigException('Model class must extend from \\yii\\db\\BaseActiveRecord'); |
||
29 | } |
||
30 | |||
31 | /** @var DatabaseMessage $message */ |
||
32 | $message = $notification->exportFor('database'); |
||
33 | list($notifiableType, $notifiableId) = $recipient->routeNotificationFor('database'); |
||
34 | $data = [ |
||
35 | 'level' => $message->level, |
||
36 | 'subject' => $message->subject, |
||
37 | 'body' => $message->body, |
||
38 | 'notifiable_type' => $notifiableType, |
||
39 | 'notifiable_id' => $notifiableId, |
||
40 | ]; |
||
41 | |||
42 | if ($model->load($data, '')) { |
||
43 | return $model->insert(); |
||
44 | } |
||
45 | |||
46 | return false; |
||
47 | } |
||
48 | } |