active-record
active-record copied to clipboard
Summary for `ActiveRecord`
- [x] 1. Rename
BaseActiveRecordclass toAbstractActiveRecord - [x] 2. Make
AbstractActiveRecordclass implements onlyActiveRecordInterface - [x] 3. Move other interfaces to
ActiveRecordclass - [x] 4. Move implementation of the interfaces to traits
- [x] 5. Move
$propertieswith magic methods__get(),__set(),__isset(),__unset()toMagicPropertiesTraitand use it inActiveRecordclass - [x] ~6. Access to properties values inside
AbstractActiveRecordvia$this->$nameonly~ - [x] 7. To get a relation query instance of
ActiveQueryInterfaceuse method with prefixgetand suffixQuery, e.g.getOrderQuery(): ActiveQueryInterfaceinstead ofgetOrder(): ActiveQueryInterface - [x] 8. To get a relation value use method with prefix
get, e.g.getOrder(): ActiveRecordInterface|null - [x] 9. Rename method
getRelation(): ActiveQueryInterfacetorelationQuery(): 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
Great ideas, especially with naming for relations. I have a question:
What's the reason to rename attributes to properties?
What's the reason to rename
attributestoproperties?
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.
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.
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