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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to reference attributes by path #1

Open
MrHash opened this issue Jul 7, 2015 · 4 comments
Open

Unable to reference attributes by path #1

MrHash opened this issue Jul 7, 2015 · 4 comments

Comments

@MrHash
Copy link
Contributor

MrHash commented Jul 7, 2015

Would need to be able to reference embedded attributes by dot notation paths.

@graste graste self-assigned this Jul 7, 2015
@graste
Copy link
Member

graste commented Jul 7, 2015

I suggest we change the getValue() method on the Entity to use the AttributePath::getAttributeValueByPath() method like we do similarly to get the root type on an attribute or to get the path or value path for attributes etc.

@graste
Copy link
Member

graste commented Jul 7, 2015

ping @shrink0r The setValue method only works for the attributes of the current entity and not for nested stuff. When we introduce getValue to actually work more like a getValueByPath method should we adjust the setValue as well?

graste added a commit that referenced this issue Jul 7, 2015
This makes it easier to get nested values from an Entity. The downside
atm would be that the setValue doesn't vehave the same as it just sets
current level attributes instead of trying to change nested ones.

refs #1
@graste
Copy link
Member

graste commented Jul 21, 2015

As the getValue method name is already a candidate for collisions with attributes people use in their schemas we will make changes along the following (example):

  • getValue($attribute_name) => get($name, $interpret_as_path = false)
  • setValue(…) => set(…)

The get method will then by default only get attributes by their concrete name as that is consistent with the set method and doesn't involve magically getting nested attributes. The boolean flag argument will be used to trigger getting nested attributes from an entity. This can then be used in code that generically iterates over stuff or exporters, renderers, or similar that need quick access to deeply nested values. Even though the boolean flag is a bit smelly it's probably better than introducing another method like valueByPath or similar as we can't use getValueByPath as that introduces another possible method name collision.

@graste graste removed their assignment Jul 21, 2015
@graste
Copy link
Member

graste commented Jul 21, 2015

ping @shrink0r

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants