svyatoslav-kubakh /
postfix-admin
| 1 | <?php |
||||||
| 2 | namespace backend\observers; |
||||||
| 3 | |||||||
| 4 | use yii\base\ModelEvent; |
||||||
| 5 | use yii\db\AfterSaveEvent; |
||||||
| 6 | use backend\models\Log; |
||||||
| 7 | use yii\db\ActiveRecord; |
||||||
| 8 | |||||||
| 9 | class LogObserver |
||||||
| 10 | { |
||||||
| 11 | public function observeCreate(AfterSaveEvent $event) |
||||||
| 12 | { |
||||||
| 13 | Log::find() |
||||||
| 14 | ->createLogEntity( |
||||||
| 15 | self::getEntity($event), |
||||||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||||||
| 16 | Log::ACTION_CREATE, |
||||||
| 17 | false, |
||||||
| 18 | true |
||||||
| 19 | )->save(); |
||||||
| 20 | } |
||||||
| 21 | |||||||
| 22 | public function observeUpdate(ModelEvent $event) |
||||||
| 23 | { |
||||||
| 24 | Log::find() |
||||||
| 25 | ->createLogEntity( |
||||||
| 26 | self::getEntity($event), |
||||||
|
0 ignored issues
–
show
The method
backend\observers\LogObserver::getEntity() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 27 | Log::ACTION_UPDATE |
||||||
| 28 | )->save(); |
||||||
| 29 | } |
||||||
| 30 | |||||||
| 31 | public function observeDelete(ModelEvent $event) |
||||||
| 32 | { |
||||||
| 33 | Log::find() |
||||||
| 34 | ->createLogEntity( |
||||||
| 35 | self::getEntity($event), |
||||||
|
0 ignored issues
–
show
The method
backend\observers\LogObserver::getEntity() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 36 | Log::ACTION_DELETE, |
||||||
| 37 | true, |
||||||
| 38 | false |
||||||
| 39 | )->save(); |
||||||
| 40 | } |
||||||
| 41 | |||||||
| 42 | /** |
||||||
| 43 | * @param $event |
||||||
| 44 | * @return ActiveRecord |
||||||
| 45 | */ |
||||||
| 46 | protected function getEntity($event) |
||||||
| 47 | { |
||||||
| 48 | return $event->sender; |
||||||
| 49 | } |
||||||
| 50 | } |
||||||
| 51 |