Skip to content

Commit

Permalink
revision trait fix getSystemUserId
Browse files Browse the repository at this point in the history
  • Loading branch information
veneliniliev committed Dec 12, 2016
1 parent 5dca3d7 commit b7686b6
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions app/Traits/RevisionableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function boot()
{
parent::boot();

if (! method_exists(get_called_class(), 'bootTraits')) {
if (!method_exists(get_called_class(), 'bootTraits')) {
static::bootRevisionableTrait();
}
}
Expand Down Expand Up @@ -105,7 +105,7 @@ public static function classRevisionHistory($limit = 100, $order = 'desc')
*/
public function preSave()
{
if (! isset($this->revisionEnabled) || $this->revisionEnabled) {
if (!isset($this->revisionEnabled) || $this->revisionEnabled) {
// if there's no revisionEnabled. Or if there is, if it's true

$this->originalData = $this->original;
Expand All @@ -114,7 +114,7 @@ public function preSave()
// we can only safely compare basic items,
// so for now we drop any object based items, like DateTime
foreach ($this->updatedData as $key => $val) {
if (gettype($val) == 'object' && ! method_exists($val, '__toString')) {
if (gettype($val) == 'object' && !method_exists($val, '__toString')) {
unset($this->originalData[$key]);
unset($this->updatedData[$key]);
array_push($this->dontKeep, $key);
Expand Down Expand Up @@ -158,7 +158,7 @@ public function postSave()
}

// check if the model already exists
if (((! isset($this->revisionEnabled) || $this->revisionEnabled) && $this->updating) && (! $LimitReached || $RevisionCleanup)) {
if (((!isset($this->revisionEnabled) || $this->revisionEnabled) && $this->updating) && (!$LimitReached || $RevisionCleanup)) {
// if it does, it means we're updating

$changes_to_record = $this->changedRevisionableFields();
Expand Down Expand Up @@ -212,8 +212,8 @@ private function changedRevisionableFields()
foreach ($this->dirtyData as $key => $value) {
// check that the field is revisionable, and double check
// that it's actually new data in case dirty is, well, clean
if ($this->isRevisionable($key) && ! is_array($value)) {
if (! isset($this->originalData[$key]) || $this->originalData[$key] != $this->updatedData[$key]) {
if ($this->isRevisionable($key) && !is_array($value)) {
if (!isset($this->originalData[$key]) || $this->originalData[$key] != $this->updatedData[$key]) {
$changes_to_record[$key] = $value;
}
} else {
Expand Down Expand Up @@ -257,7 +257,9 @@ private function isRevisionable($key)
**/
public function getSystemUserId()
{
if (! isset($this->guard)) {
if (\ProVision\Administration\Administration::routeInAdministration()) {
$this->guard = 'provision_administration';
} else {
$this->guard = 'web';
}

Expand Down Expand Up @@ -290,7 +292,7 @@ public function postCreate()
return false;
}

if ((! isset($this->revisionEnabled) || $this->revisionEnabled)) {
if ((!isset($this->revisionEnabled) || $this->revisionEnabled)) {
$revisions[] = [
'revisionable_type' => $this->getMorphClass(),
'revisionable_id' => $this->getKey(),
Expand All @@ -313,7 +315,7 @@ public function postCreate()
*/
public function postDelete()
{
if ((! isset($this->revisionEnabled) || $this->revisionEnabled)
if ((!isset($this->revisionEnabled) || $this->revisionEnabled)
&& $this->isSoftDelete()
&& $this->isRevisionable($this->getDeletedAtColumn())
) {
Expand Down Expand Up @@ -342,7 +344,7 @@ private function isSoftDelete()
{
// check flag variable used in laravel 4.2+
if (isset($this->forceDeleting)) {
return ! $this->forceDeleting;
return !$this->forceDeleting;
}

// otherwise, look for flag used in older versions
Expand Down Expand Up @@ -421,7 +423,7 @@ public function getRevisionUnknownString()
*/
public function disableRevisionField($field)
{
if (! isset($this->dontKeepRevisionOf)) {
if (!isset($this->dontKeepRevisionOf)) {
$this->dontKeepRevisionOf = [];
}
if (is_array($field)) {
Expand Down

0 comments on commit b7686b6

Please sign in to comment.