Skip to content

Commit 25dc80b

Browse files
authored
Add support for whole-entity hasChanged()
1 parent 4699642 commit 25dc80b

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

system/Entity.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,20 @@ public function syncOriginal()
236236

237237
/**
238238
* Checks a property to see if it has changed since the entity was created.
239+
* Or, without a parameter, checks if any properties have changed.
239240
*
240-
* @param string $key
241+
* @param ?string $key
241242
*
242243
* @return boolean
243244
*/
244-
public function hasChanged(string $key): bool
245+
public function hasChanged(string $key = null): bool
245246
{
247+
// If no parameter was given then check all attributes
248+
if ($key === null)
249+
{
250+
return $this->original !== $this->attributes;
251+
}
252+
246253
// Key doesn't exist in either
247254
if (! array_key_exists($key, $this->original) && ! array_key_exists($key, $this->attributes))
248255
{

0 commit comments

Comments
 (0)