From b99fdc11caceb20150bc3373c70a2e2d457df632 Mon Sep 17 00:00:00 2001 From: PhilippGrashoff <33204878+PhilippGrashoff@users.noreply.github.com> Date: Thu, 14 Sep 2023 22:07:33 +0200 Subject: [PATCH] Update docs about dirty fields and after save hook (#1131) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michael Voříšek --- docs/typecasting.md | 3 +-- src/Model.php | 19 +++---------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/docs/typecasting.md b/docs/typecasting.md index 473831ce3..25996000c 100644 --- a/docs/typecasting.md +++ b/docs/typecasting.md @@ -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 diff --git a/src/Model.php b/src/Model.php index fb4552b75..276088dd2 100644 --- a/src/Model.php +++ b/src/Model.php @@ -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; @@ -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 */ private array $dirty = []; @@ -230,8 +225,6 @@ class Model implements \IteratorAggregate /** Only for Reference class */ public ?Reference $ownerReference = null; - // }}} - // {{{ Basic Functionality, field definition, set() and get() /** @@ -946,7 +939,7 @@ public function _unset(string $name) // }}} - // {{{ DataSet logic + // {{{ Model logic /** * Get the scope object of the Model. @@ -1945,10 +1938,6 @@ public function executeCountQuery(): int return $res; } - // }}} - - // {{{ Expressions - /** * Add expression field. * @@ -1984,8 +1973,6 @@ public function addCalculatedField(string $name, $seed) return $field; } - // }}} - public function __isset(string $name): bool { $model = $this->getModel(true);