From 4e91446619715821fae0c0b4438100280945bf5e Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sun, 8 Jan 2017 00:11:47 +0100 Subject: [PATCH] Clean up --- src/AppBundle/Model/BaseModel.php | 16 +++++++--------- src/AppBundle/Model/Folder.php | 2 +- src/AppBundle/Model/Note.php | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/AppBundle/Model/BaseModel.php b/src/AppBundle/Model/BaseModel.php index ac8b9a513..c5a1b8cf7 100755 --- a/src/AppBundle/Model/BaseModel.php +++ b/src/AppBundle/Model/BaseModel.php @@ -11,15 +11,13 @@ class BaseModel extends \Illuminate\Database\Eloquent\Model { public $timestamps = false; public $useUuid = false; protected $changedVersionedFieldValues = array(); - protected $versionedFields = array(); + protected $diffableFields = array(); protected $isVersioned = false; private $isNew = null; private $revId = 0; static private $clientId = null; - static protected $enums = array( - 'field' => array('title', 'body', 'completed'), - ); + static protected $enums = array(); static protected $defaultValidationRules = array(); static protected $defaultValidationMessages = array( 'required' => '{key} is required', @@ -133,7 +131,7 @@ class BaseModel extends \Illuminate\Database\Eloquent\Model { foreach ($array as $k => $v) { if ($k == 'rev_id') { $this->revId = $v; - } else if (in_array($k, $this->versionedFields)) { + } else if (in_array($k, $this->diffableFields)) { $this->changedVersionedFieldValues[$k] = $v; } else { $this->{$k} = $v; @@ -164,7 +162,7 @@ class BaseModel extends \Illuminate\Database\Eloquent\Model { } $maxRevId = 0; - foreach ($this->versionedFields as $field) { + foreach ($this->diffableFields as $field) { $r = $this->versionedFieldValue($field, true); $output[$field] = $r['text']; $maxRevId = max($maxRevId, $r['revId']); @@ -343,7 +341,7 @@ class BaseModel extends \Illuminate\Database\Eloquent\Model { public function delete() { $output = parent::delete(); - if (count($this->versionedFields)) { + if (count($this->isVersioned)) { $this->recordChanges('delete'); } @@ -361,11 +359,11 @@ class BaseModel extends \Illuminate\Database\Eloquent\Model { // // When recording an "update" event, all the modified fields are recorded. foreach ($changedFields as $field => $value) { - if ($type == 'create' && !in_array($field, $this->versionedFields)) continue; + if ($type == 'create' && !in_array($field, $this->diffableFields)) continue; $change = $this->newChange($type); $change->item_field = $field; - if (in_array($field, $this->versionedFields)) $change->createDelta($changedFields[$field]); + if (in_array($field, $this->diffableFields)) $change->createDelta($changedFields[$field]); $change->save(); } } else { diff --git a/src/AppBundle/Model/Folder.php b/src/AppBundle/Model/Folder.php index 553e4462b..0011eda0d 100755 --- a/src/AppBundle/Model/Folder.php +++ b/src/AppBundle/Model/Folder.php @@ -4,7 +4,7 @@ namespace AppBundle\Model; class Folder extends BaseItem { - protected $versionedFields = array('title'); + protected $diffableFields = array('title'); protected $isVersioned = true; public function add($ids) { diff --git a/src/AppBundle/Model/Note.php b/src/AppBundle/Model/Note.php index 4b8b62432..dedd3072c 100755 --- a/src/AppBundle/Model/Note.php +++ b/src/AppBundle/Model/Note.php @@ -4,7 +4,7 @@ namespace AppBundle\Model; class Note extends BaseItem { - protected $versionedFields = array('title', 'body'); + protected $diffableFields = array('title', 'body'); protected $isVersioned = true; }