Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Model\ArrayAccessTrait trait #958

Merged
merged 1 commit into from Jan 9, 2022

Conversation

mvorisek
Copy link
Member

@mvorisek mvorisek commented Jan 9, 2022

Use hintable instead: it allows you to access/set field values as if there were properties, in reality, the properties are virtualized based on phpdoc above the model class
to use it, you need to define each property incl. the type, above your model classes, see ui demos or https://github.com/mvorisek/atk4-hintable-mirror/blob/develop/tests/Data/Model/Standard.php and https://github.com/mvorisek/atk4-hintable-mirror/blob/develop/tests/Data/HintableModelArrayTest.php

the advantage is much shorter code which supports refactoring incl. type checking, field names are refactorable using brutal magic too like $model->fieldName()->customer_name 馃槈

also all traversing is then as simple as $customer->address->city instead of $customer->ref('address')->get('city')

@mvorisek mvorisek merged commit 72aadc0 into develop Jan 9, 2022
@mvorisek mvorisek deleted the del_model_array_access_trait branch January 9, 2022 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant