public function actionDiff($document_history_id)
 {
     $model = History::findOne($document_history_id);
     if (is_null($model)) {
         throw new \yii\web\HttpException(404, Yii::t('burivuh', 'Record in the history does not exist'));
     }
     $document = Document::findOne($model->document_id);
     $previous = History::find()->where(['document_id' => $model->document_id])->andWhere('created_at<:created_at', [':created_at' => $model->created_at])->orderBy('created_at DESC')->limit(1)->one();
     $diffs = [];
     if (!is_null($previous)) {
         $dmp = new DiffMatchPatch();
         $diffs = $dmp->diff_main($previous->content, $model->content, false);
     }
     return $this->render('diff', ['document' => $document, 'model' => $model, 'previous' => $previous, 'diffs' => $diffs]);
 }
Beispiel #2
0
 public function getHistory()
 {
     return $this->hasMany(History::className(), ['document_id' => 'document_id'])->orderBy('created_at DESC');
 }