public function renderSlotContents($contents, $slotProperties) { $name = isset($slotProperties['name']) ? $slotProperties['name'] : ''; $title = sprintf('Slot %s [%d]', $name, $slotProperties['id']); $this->stopwatch->start($title, 'Jarves'); if (is_string($contents)) { return $contents; } if (!$contents instanceof \Traversable) { return; } $filteredContents = $this->filterContentsForAccess($contents); $count = count($filteredContents); /* * Compatibility */ $data['layoutContentsMax'] = $count; $data['layoutContentsIsFirst'] = true; $data['layoutContentsIsLast'] = false; $data['layoutContentsId'] = @$slotProperties['id']; $data['layoutContentsName'] = @$slotProperties['name']; $i = 0; //$oldContent = $tpl->getTemplateVars('content'); $this->eventDispatcher->dispatch('core/render/slot/pre', new GenericEvent($data)); $html = ''; if ($count > 0) { foreach ($filteredContents as $content) { if (is_string($content)) { $html .= $content; continue; } if ('stopper' === $content->getType()) { if ($html) { break; } continue; } if ($i == $count) { $data['layoutContentsIsLast'] = true; } if ($i > 0) { $data['layoutContentsIsFirst'] = false; } $i++; $data['layoutContentsIndex'] = $i; $html .= $this->renderContent($content, $data); } } $argument = array($data, &$html); $this->eventDispatcher->dispatch('core/render/slot', new GenericEvent($argument)); $this->stopwatch->stop($title); return $html; }