active-record icon indicating copy to clipboard operation
active-record copied to clipboard

Summary for `ActiveRecord`

Open Tigrov opened this issue 1 year ago • 4 comments

  • [x] 1. Rename BaseActiveRecord class to AbstractActiveRecord
  • [x] 2. Make AbstractActiveRecord class implements only ActiveRecordInterface
  • [x] 3. Move other interfaces to ActiveRecord class
  • [x] 4. Move implementation of the interfaces to traits
  • [x] 5. Move $properties with magic methods __get(), __set(), __isset(), __unset() to MagicPropertiesTrait and use it in ActiveRecord class
  • [x] ~6. Access to properties values inside AbstractActiveRecord via $this->$name only~
  • [x] 7. To get a relation query instance of ActiveQueryInterface use method with prefix get and suffix Query, e.g. getOrderQuery(): ActiveQueryInterface instead of getOrder(): ActiveQueryInterface
  • [x] 8. To get a relation value use method with prefix get, e.g. getOrder(): ActiveRecordInterface|null
  • [x] 9. Rename method getRelation(): ActiveQueryInterface to relationQuery(): ActiveQueryInterface
  • [x] 10. Add method to get a value of relation relation(string $name): ActiveRecordInterface|null {return $this->related[$name] ?? null;}
  • [x] 11. Split magical and non-magical implementations
  • [ ] 12. Test traits and concrete implementations separately
  • [ ] 13. Update documentation

Tigrov avatar May 03 '24 07:05 Tigrov

Great ideas, especially with naming for relations. I have a question: What's the reason to rename attributes to properties?

xepozz avatar May 14 '24 18:05 xepozz

What's the reason to rename attributes to properties?

It was discussed that there is confusion between the $attributes AR property and PHP's #[Attribute].

But it's a good question. Now this looks doubtful due to major changes and needs to be discussed again. Due to the renaming of public methods whose names contain attribute.

Tigrov avatar May 15 '24 04:05 Tigrov

But it's a good question. Now this looks doubtful due to major changes and needs to be discussed again. Due to the renaming of public methods whose names contain attribute.

Are there any pitfalls here? Rename methods also it looks logically.

vjik avatar May 18 '24 17:05 vjik

Are there any pitfalls here? Rename methods also it looks logically.

Discussion about renaming $attributes moved to https://github.com/yiisoft/active-record/issues/343

Tigrov avatar May 19 '24 02:05 Tigrov