ivankff / yii2-log-after-save
yii2 save logs after AR saving
Package info
github.com/ivankff/yii2-log-after-save
Type:yii2-extension
pkg:composer/ivankff/yii2-log-after-save
0.1.1
2020-06-26 14:04 UTC
Requires
- yiisoft/yii2: ~2.0
Requires (Dev)
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2026-02-27 01:53:22 UTC
README
ActiveRecord
/** * @param int $statusId * @param string|null $comment */ public function setStatus($statusId, $comment = null) { $this->setAttribute('status_id', $statusId); $this->_addLog(new StatusLog(['order_id' => $this->id, 'status_id' => $statusId, 'comment' => $comment])); } /** * @param ActiveRecord $log */ protected function _addLog(ActiveRecord $log) { /** @var LogAfterSaveBehavior $behavior */ $behavior = $this->getBehavior(LogAfterSaveBehavior::NAME); if (! $behavior) $behavior = $this->attachBehavior(LogAfterSaveBehavior::NAME, LogAfterSaveBehavior::class); $behavior->addLog($log); }