Skip to content

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

Closed
yol wants to merge 1 commit into
FluidTYPO3:developmentfrom
yol:set-vh-nesting
Closed

[FEATURE] Support nesting in v:variable.set#1514
yol wants to merge 1 commit into
FluidTYPO3:developmentfrom
yol:set-vh-nesting

Conversation

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

Like this: TYPO3/Fluid#425 ;)

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