ivankff / yii2-log-after-save
yii2 save logs after AR saving
Installs: 49
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: ~2.0
Requires (Dev)
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2025-02-26 23:46:40 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); }