From b482833bf07dc5ecdd44903c7e553961c61f3e11 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Tue, 21 May 2024 18:15:57 +0700 Subject: [PATCH] Add `MagicActiveRecord` --- src/ActiveRecord.php | 18 ++++++---------- src/MagicActiveRecord.php | 44 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 src/MagicActiveRecord.php diff --git a/src/ActiveRecord.php b/src/ActiveRecord.php index f2a7f830e..d86cd9b37 100644 --- a/src/ActiveRecord.php +++ b/src/ActiveRecord.php @@ -9,25 +9,21 @@ use Yiisoft\ActiveRecord\Trait\ArrayableTrait; use Yiisoft\ActiveRecord\Trait\ArrayAccessTrait; use Yiisoft\ActiveRecord\Trait\ArrayIteratorTrait; -use Yiisoft\ActiveRecord\Trait\MagicPropertiesTrait; -use Yiisoft\ActiveRecord\Trait\MagicRelationsTrait; use Yiisoft\ActiveRecord\Trait\TransactionalTrait; use Yiisoft\Arrays\ArrayableInterface; /** * Active Record class which implements {@see ActiveRecordInterface} and provides additional features like: * - * - {@see ArrayableInterface}: to convert the object into an array; - * - {@see ArrayAccess}: to access attributes as array elements; - * - {@see IteratorAggregate}: to iterate over attributes; - * - {@see TransactionalInterface}: to handle transactions; - * - {@see MagicPropertiesTrait}: to access attributes as properties; - * - {@see MagicRelationsTrait}: to access relation queries. - * - * @see BaseActiveRecord for more information. + * @see ArrayableInterface to convert the object into an array; + * @see ArrayAccess to access attributes as array elements; + * @see IteratorAggregate to iterate over attributes; + * @see TransactionalInterface to handle transactions; * * @template-implements ArrayAccess * @template-implements IteratorAggregate + * + * @see BaseActiveRecord for more information. */ class ActiveRecord extends BaseActiveRecord implements ArrayableInterface, @@ -38,7 +34,5 @@ class ActiveRecord extends BaseActiveRecord implements use ArrayableTrait; use ArrayAccessTrait; use ArrayIteratorTrait; - use MagicPropertiesTrait; - use MagicRelationsTrait; use TransactionalTrait; } diff --git a/src/MagicActiveRecord.php b/src/MagicActiveRecord.php new file mode 100644 index 000000000..e0b5b62d1 --- /dev/null +++ b/src/MagicActiveRecord.php @@ -0,0 +1,44 @@ + + * @template-implements IteratorAggregate + * + * @see BaseActiveRecord for more information. + */ +class MagicActiveRecord extends BaseActiveRecord implements + ArrayableInterface, + ArrayAccess, + IteratorAggregate, + TransactionalInterface +{ + use ArrayableTrait; + use ArrayAccessTrait; + use ArrayIteratorTrait; + use TransactionalTrait; + use MagicPropertiesTrait; + use MagicRelationsTrait; +}