Вместо того, чтобы делать это рендеринг каждого слайда в моей веток, как это (см. Строку 6): < /p>
{# loop out the slides #}
{% for c in contents %}
{% set i=i+1 %} {# increase slide number #}
{# the slide itself, rendered by it's own template #}
{% include 'BizTVArchiveBundle:ContentTemplate:'~c.template~'/view.html.twig' with {'contents': c, 'ordernumber': i} %}
{% endfor %}
< /code>
...instead Я хотел бы сохранить всю эту логику в контроллере, чтобы просто доставить в просмотр массива готовых слайдов. Как я могу сделать что -то подобное (см. Строку 9): < /p>
//do stuff...
foreach ($container->getContent() as $c) {
$content[$i]['title'] = $c->getTitle();
$content[$i]['sort'] = $c->getSortOrder();
$content[$i]['data'] = $c->getData();
$content[$i]['template'] = $c->getTemplate()->getId();
$content[$i]['duration'] = $this->extract_seconds($c);
$content[$i]['html'] = $this->render('BizTVArchiveBundle:ContentTemplate:'.$content[$i]['template'].'/view.html.twig', array(
'contents'=> $content[$i],
'ordernumber' => 99,
));
}
< /code>
Все, что он дает мне в данный момент (содержимое $ content [$ i] ['html']) - < /p>
{"headers":{}}
Подробнее здесь: https://stackoverflow.com/questions/209 ... -later-use