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

[FEATURE] iterator.merge: Allow use in a chain #757

Merged

Conversation

neufeind
Copy link
Contributor

Allow use like:
{abc -> v:iterator.merge(a: def)}

This makes it easier to join multiple arrays
in a row and also to workaround some cases
where the Fluid-parser might otherwise
have a hard time.

@NamelessCoder
Copy link
Member

This is an automated comment based on an automated formal commit review.

Your pull request contains formal errors. Comments have been assigned to each commit in your pull request - please review and adjust. Feel free to ask for help if you need it!

@NamelessCoder
Copy link
Member

Suggested method body:

    /**
     * Merges arrays/Traversables $a and $b into an array
     *
     * @param mixed $b Second array/Traversable
     * @param mixed $a First array/Traversable
     * @param boolean $useKeys If TRUE, comparison is done while also observing (and merging) the keys used in each array
     * @return array
     */
    public function render($b, $a = NULL, $useKeys = TRUE) {
        if (NULL === $a) {
            $a = $this->renderChildren();
        }
        $a = ViewHelperUtility::arrayFromArrayOrTraversableOrCSV($a, $useKeys);
        $b = ViewHelperUtility::arrayFromArrayOrTraversableOrCSV($b, $useKeys);
        $merged = GeneralUtility::array_merge_recursive_overrule($a, $b);
        return $merged;
    }
  • Matches usages of v:math.* arguments a/b.
  • Gets by with a single use of recursive array merging
  • Is somewhat easier to follow, logic-wise

Allow use like:
{abc -> v:iterator.merge(b: def)}

This makes it easier to join multiple arrays
in a row and also to workaround some cases
where the Fluid-parser might otherwise
have a hard time.
@neufeind neufeind force-pushed the feature/iterator-merge-chain branch from afa7b5f to 036b60c Compare January 24, 2015 20:53
@neufeind
Copy link
Contributor Author

Pushed new version like you suggested. I'm unsure if we should demand a or b to be set, so the original idea was to still allow to be use both :-) But I'm also fine with the current solution.
Added adjusted commit-msg. Be sure the correct one is used upon merge. (I'm not sure github picks the right one.)

NamelessCoder added a commit that referenced this pull request Jan 24, 2015
[FEATURE] iterator.merge: Allow use in a chain
@NamelessCoder NamelessCoder merged commit c66d835 into FluidTYPO3:development Jan 24, 2015
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.

2 participants