Skip to content

[FEATURE] Support nesting in v:variable.set #1514

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

Closed
wants to merge 1 commit into from

Conversation

yol
Copy link
Contributor

@yol yol commented Sep 12, 2018

SetViewHelper could only set direct child properties of arrays or
objects before, which is inconvenient when working with nested
structures. This change adds code to access properties nested at
arbitrary levels inside mixed array/object hierarchies.

This is actually much more complicated then I'd like, but so far I haven't found an easy way around it. Suggestions to make it more readable very welcome. Maybe there's already a helper function for this somewhere that I missed?

SetViewHelper could only set direct child properties of arrays or
objects before, which is inconvenient when working with nested
structures. This change adds code to access properties nested at
arbitrary levels inside mixed array/object hierarchies.
@NamelessCoder
Copy link
Member

I think we should solve this in Fluid instead, making it possible to assign('variable.with.path', 'value'). This could be done in VariableProvider´s add() method by checking if $identifier contains a dot and if it does, https://github.com/NamelessCoder/typo3-cms-data-processors/blob/master/Classes/StructuredVariablesProcessor.php#L82 should give some inspiration how we could handle that one (and by the way... implementing this in Fluid makes that package obsolete).

The code on the link uses ObjectAccess and obviously Fluid can't do that - instead it can use the internal methods on VariableProvider that resolves a value. We can change those methods so they return references to avoid the deference-if-parent-is-array problem described in the comment.

Then after all that we should simply deprecate the VHS ViewHelper.

@NamelessCoder
Copy link
Member

Like this: TYPO3/Fluid#425 ;)

@yol
Copy link
Contributor Author

yol commented Jan 7, 2019

As long as it works and the feature set is roughly the same as with vhs - sure :-) Thanks for the PR.

@NamelessCoder
Copy link
Member

Closing this one, will pursue getting the Fluid-native feature merged.

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

Successfully merging this pull request may close these issues.

3 participants