Skip to content

Commit

Permalink
Update docs about dirty fields and after save hook (#1131)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Voříšek <mvorisek@mvorisek.cz>
  • Loading branch information
PhilippGrashoff and mvorisek authored Sep 14, 2023
1 parent 605b85f commit b99fdc1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
3 changes: 1 addition & 2 deletions docs/typecasting.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ $m->save();
```

Typecasting is necessary to save the values inside the database and restore
them back just as they were before. When modifying a record, typecasting will
only be invoked on the fields which were dirty.
them back just as they were before.

The purpose of a flexible typecasting system is to allow you to store your date
in a compatible format or even fine-tune it to match your database settings
Expand Down
19 changes: 3 additions & 16 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ class Model implements \IteratorAggregate
protected const ID_LOAD_ONE = self::class . '@idLoadOne-h7axmDNBB3qVXjVv';
protected const ID_LOAD_ANY = self::class . '@idLoadAny-h7axmDNBB3qVXjVv';

// {{{ Properties of the class

/** @var static|null not-null if and only if this instance is an entity */
private ?self $_model = null;

Expand Down Expand Up @@ -149,17 +147,14 @@ class Model implements \IteratorAggregate
private array $data = [];

/**
* After loading an active record from DataSet it will be stored in
* $data property and you can access it using get(). If you use
* After loading an entity the data will be stored in
* $data property and you can access them using get(). If you use
* set() to change any of the data, the original value will be copied
* here.
*
* If the value you set equal to the original value, then the key
* in this array will be removed.
*
* The $dirty data will be reset after you save() the data but it is
* still available to all before/after save handlers.
*
* @var array<string, mixed>
*/
private array $dirty = [];
Expand Down Expand Up @@ -230,8 +225,6 @@ class Model implements \IteratorAggregate
/** Only for Reference class */
public ?Reference $ownerReference = null;

// }}}

// {{{ Basic Functionality, field definition, set() and get()

/**
Expand Down Expand Up @@ -946,7 +939,7 @@ public function _unset(string $name)

// }}}

// {{{ DataSet logic
// {{{ Model logic

/**
* Get the scope object of the Model.
Expand Down Expand Up @@ -1945,10 +1938,6 @@ public function executeCountQuery(): int
return $res;
}

// }}}

// {{{ Expressions

/**
* Add expression field.
*
Expand Down Expand Up @@ -1984,8 +1973,6 @@ public function addCalculatedField(string $name, $seed)
return $field;
}

// }}}

public function __isset(string $name): bool
{
$model = $this->getModel(true);
Expand Down

0 comments on commit b99fdc1

Please sign in to comment.