Feature #9514

Support explicit Array Arguments for ViewHelpers

Added by Sebastian Kurfuerst over 10 years ago. Updated over 9 years ago.

Should have
Target version:
Start date:
Due date:
% Done:


Estimated time:
Has patch:


We have been brainstorming over some additions to fluid syntax.

  • Imagine you have a ViewHelper with the following Render Method signature:
    function render(array $bla)
  • then it would be very nice if one could write the following:
    <f:xy arr.someArrayKey="foo" /> // "foo" is not validated, as we do not have any more type information.
  • Additionally, one could override specific key/value pairs of array arguments:
    <f:xy arr="{myArray}" arr.someArrayKey="foo" /> // "foo" is merged into {myArray}

Additionally, one could register specific array keys, and validate them. Imagine the following argument registration:
$this->registerArgument('foo.bar', 'boolean', REQUIRED=TRUE);

  • Now, it is validated that foo.bar is a boolean value, which exists; so you would know that $this->arguments['foo']['bar'] is really a boolean and it is set.

What needs to be changed internally:

On compile time:

  • TemplateParser->abortIfUnregisteredArgumentsExist($expectedViewHelperArguments, $argumentsObjectTree);
    • if Argument name is "bla.blubb", check that either the argument "bla.blubb" or the argument "bla" has been explicitely registered (and "bla" is an array)
  • TemplateParser->abortIfRequiredArgumentsAreMissing($expectedViewHelperArguments, $argumentsObjectTree);
    • do not abort if "bla.blubb" is not registered, but "bla" is.

On run-time: Type checking

  • change validateArguments in AbstractVH
    1. MERGING von "arr.abcde" und "arr" (Punkt-Syntax ├╝berschreibt)
    2. VALIDIERUNG (von allen regeln) -> d.h. wenn es eine Regel "arr.abcde" gibt, dann wird geschaut ob es diesen Array Key gibt

Examples of possible usage

<f:widget.paginate objects="{posts}" configuration.position="top" configuration.itemsPerPage="3" configuration.linkCurrent="false" /> <==>
<f:widget.paginate objects="{posts}" configuration="{position: 'top', itemsPerPage: 3, linkCurrent: 'false'}" />

Shorthand Sxntax

Will work like the explicit syntax:
{f:widget.paginate(objects: posts, configuration.position: 'top')}

However, for Arrays, this is NOT ALLOWED: {foo: {bar: '123'}} {foo.bar: '123', foo: {bar: '123'}} < this should be forbidden!


Updated by Sebastian Kurfuerst over 9 years ago

  • Tracker changed from Major Feature to Story

Updated by Sebastian Kurfuerst over 9 years ago

  • Tracker changed from Story to Feature

Also available in: Atom PDF