Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
better accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfy-j committed Feb 8, 2017
1 parent 0380f47 commit db4eb55
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion source/Spiral/ODM/Accessors/AbstractArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ abstract class AbstractArray implements CompositableInterface, \Countable, \Iter
{
use SolidableTrait;

/**
* When value changed directly.
*
* @var bool
*/
private $changed = false;

/**
* @var array
*/
Expand Down Expand Up @@ -142,6 +149,7 @@ public function setValue($data)
{
//Manually altered arrays must always end in solid state
$this->solidState = true;
$this->changed = true;

//Flushing existed values
$this->values = [];
Expand All @@ -155,14 +163,15 @@ public function setValue($data)
*/
public function hasChanges(): bool
{
return !empty($this->atomics);
return $this->changed || !empty($this->atomics);
}

/**
* {@inheritdoc}
*/
public function flushChanges()
{
$this->changed = false;
$this->atomics = [];
}

Expand Down

0 comments on commit db4eb55

Please sign in to comment.