* @copyright 2016-2024 Daniil Gentili * @license https://opensource.org/license/apache-2-0 Apache 2.0 * @link https://github.com/danog/AsyncOrm AsyncOrm documentation */ namespace danog\TestAsyncOrm; use danog\AsyncOrm\Annotations\OrmMappedArray; use danog\AsyncOrm\DbArray; use danog\AsyncOrm\DbAutoProperties; use danog\AsyncOrm\DbObject; use danog\AsyncOrm\DbArrayBuilder; use danog\AsyncOrm\KeyType; use danog\AsyncOrm\ValueType; final class TestObject extends DbObject { use DbAutoProperties; public int $loadedCnt = 0; public int $saveAfterCnt = 0; public int $saveBeforeCnt = 0; public mixed $savedProp = null; #[OrmMappedArray( KeyType::INT, ValueType::INT )] public DbArray $arr; #[OrmMappedArray( KeyType::INT, ValueType::INT )] public DbArray $arr2; public function __sleep() { return ['savedProp', 'arr']; } protected function onLoaded(DbArrayBuilder $config): void { $this->initDbProperties($config->settings, $config->table); $this->loadedCnt++; } protected function onAfterSave(): void { $this->saveAfterCnt++; } protected function onBeforeSave(): void { $this->saveDbProperties(); $this->saveBeforeCnt++; } }