/** * Re-inflates and unserializes a blob of compressed data * @param string $data * @return mixed false if an error occurred */ public static function unserialize($data) { if (Auditing::current()->compressData) { $data = gzuncompress($data); } return unserialize($data); }
public function publish($assetManager) { $module = \bedezign\yii2\audit\Auditing::current(); if ($module && $module->entry) { // We can't be sure that the actual logger was loaded already, so we fallback on the window object // to store the associated audit entry id \Yii::$app->view->registerJs("window.auditEntry = {$module->entry->id};", \yii\web\View::POS_HEAD); } return parent::publish($assetManager); }
public function logException($exception) { try { $auditing = Auditing::current(); // Make sure not to interfere with out of memory errors, there's not enough spare room to load everything if ($auditing && strncmp($exception->getMessage(), 'Allowed memory size of', 22)) { $entry = $auditing->getEntry(true); if ($entry) { AuditError::log($entry, $exception); $entry->finalize(); } } } catch (\Exception $e) { } parent::logException($exception); }
/** * @return models\AuditEntry|null|static */ protected function getAuditEntryId() { $entry = Auditing::current() ? Auditing::current()->getEntry() : null; if ($entry) { return $entry->id; } return null; }
public static function getDb() { return Auditing::current() ? Auditing::current()->getDb() : parent::getDb(); }
<?php use bedezign\yii2\audit\Auditing; use yii\helpers\Html; /** @var yii\web\View $this */ /** @var bedezign\yii2\audit\models\AuditEntry $entry */ /** @var bool $link */ if ($auditEntry = Auditing::current()->getEntry()) { $style = YII_DEBUG ? '' : 'color:transparent;'; $link = isset($link) && $link ? $link : false; if ($link) { echo Html::a('audit-' . $auditEntry->id, ['/auditing/default/view', 'id' => $auditEntry->id], ['style' => $style]); } else { echo Html::tag('span', 'audit-' . $auditEntry->id, ['style' => $style]); } }