iterable-to-array 

Class: \CPSIT\Typo3Handlebars\DataProcessing\IterableToArrayProcessor

Converts an iterable value — an Extbase QueryResultInterface as returned by a repository, an ObjectStorage , a plain Iterator , or a Generator — into a plain array. Templates and other data processors generally expect array data, so this processor is the usual bridge between a repository result and the rest of the dataProcessing chain.

Data sources 

iterable is resolved exactly like dataSource on process-each — see Resolving a data payload (dataSource / data) for the full syntax, including what happens when multiple references are configured. It just uses a processor-specific option name instead of the generic dataSource . iterable.current uses the content object's current value instead (see Using the content object's current value).

This is what allows iterable to refer to a value placed into processedData by a preceding processor's as option, or to a variable an Extbase controller assigned directly to the view (Extbase-assigned view variables end up in processedData too, under the assigned key).

Usage 

EXT:my_extension/Classes/Controller/NewsController.php
final class NewsController extends HandlebarsController
{
    public function listAction(): ResponseInterface
    {
        $this->view->assign('news', $this->newsRepository->findAll());

        return $this->htmlResponse($this->renderView());
    }
}
Copied!
plugin.tx_myextension_news.handlebars {
    News::list {
        dataProcessing {
            10 = iterable-to-array
            10 {
                iterable = processedData:news
                as = newsItems
            }
        }
    }
}
Copied!

Processing individual items 

Each converted item is exposed to a nested dataProcessing chain as currentValue , reachable as contentObjectConfiguration:currentValue (see Data sources). This only happens when a nested chain is actually configured, so plain conversions are left untouched:

dataProcessing {
    10 = iterable-to-array
    10 {
        iterable = processedData:news
        as = newsItems

        dataProcessing {
            10 = object-access
            10 {
                object = contentObjectConfiguration:currentValue
                path = title
                as = title
            }
        }
    }
}
Copied!

Properties 

iterable
Data source reference(s) the value to convert is read from (see Data sources). Required.
as
Target key in the processed data array the resulting array is stored under. Default: result .
preserveKeys
Boolean. When 1 , the original keys of the iterable (e.g. array keys or Generator keys) are preserved. When 0 , the result is reindexed as a plain list. Default: 0 .
dataProcessing
Nested data processors, run for each item of the converted array (see Processing individual items).

If iterable is not configured, or the resolved value is not iterable, a warning is logged and the processed data is returned unchanged.