Skip to content

Remove Model\ArrayAccessTrait trait#958

Merged
mvorisek merged 1 commit intodevelopfrom
del_model_array_access_trait
Jan 9, 2022
Merged

Remove Model\ArrayAccessTrait trait#958
mvorisek merged 1 commit intodevelopfrom
del_model_array_access_trait

Conversation

@mvorisek
Copy link
Copy Markdown
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

Development

Successfully merging this pull request may close these issues.

1 participant