コード例 #1
0
 protected function buildSearchQuery($subject)
 {
     return AuditTrailEntry::find()->prepareQuery($subject);
 }
コード例 #2
0
 /**
  * Gathers the updated values
  * 
  * @param \dpodium\yii2\audittrail\models\AuditTrailEntry $entry
  * @return \dpodium\yii2\audittrail\models\AuditTrailEntry the entry
  */
 protected function getChangedValues($entry, $event)
 {
     foreach ($this->getRelevantDbAttributes() as $attrName) {
         $oldVal = null;
         $newVal = $this->owner->{$attrName} !== '' ? $this->owner->{$attrName} : null;
         if ($entry->type == static::AUDIT_TYPE_UPDATE) {
             if (!isset($event->changedAttributes[$attrName])) {
                 continue;
             }
             $oldVal = $event->changedAttributes[$attrName] !== '' ? $event->changedAttributes[$attrName] : null;
         }
         if ($oldVal != $newVal) {
             $entry->setChange($attrName, $oldVal, $newVal);
         }
     }
     if ($this->enableBenchmark) {
         $entry->picoseconds_collect_data = round((microtime(true) - $this->milestoneTime) * pow(10, 6));
         $this->milestoneTime = microtime(true);
     }
     return $entry;
 }