private function renderPage($layoutFile = null, $params = null)
    {
        $this->setNode($this->getObject());

        $application = $this->getApplication();
        // Rendering subcontent
        if (null !== $contentSet = $this->getObject()->getContentSet()) {
            $bbUserToken = $application->getBBUserToken();
            $revisionRepo = $application->getEntityManager()->getRepository('BackBee\ClassContent\Revision');
            if (null !== $bbUserToken && null !== $revision = $revisionRepo->getDraft($contentSet, $bbUserToken)) {
                $contentSet->setDraft($revision);
            }

            $layout = $this->getObject()->getLayout();
            $zones = $layout->getZones();
            $zoneIndex = 0;

            foreach ($contentSet->getData() as $content) {
                if (array_key_exists($zoneIndex, $zones)) {
                    $zone = $zones[$zoneIndex];
                    $isMain = null !== $zone && property_exists($zone, 'mainZone') && true === $zone->mainZone;
                    $this->container()->add($this->render($content, $this->getMode(), array(
                        'class' => 'rootContentSet',
                        'isRoot' => true,
                        'indexZone' => $zoneIndex++,
                        'isMainZone' => $isMain,
                    ), null, $this->_ignoreIfRenderModeNotAvailable));
                }
            }
        }

        // Check for a valid layout file
        $this->templateFile = $layoutFile;
        if (null === $this->templateFile) {
            $this->templateFile = $this->getLayoutFile($this->getCurrentPage()->getLayout());
        }

        if (!$this->isValidTemplateFile($this->templateFile, true)) {
            throw new RendererException(
                sprintf('Unable to read layout %s.', $this->templateFile), RendererException::LAYOUT_ERROR
            );
        }

        $application->info(sprintf('Rendering page `%s`.', $this->getObject()->getNormalizeUri()));

        return $this->renderTemplate(false, true);
    }