public function render($templateFilename, $vars = array(), $displayMessages = true)
 {
     $app = $this->getApplication();
     $vars['brand'] = $this->getBrand();
     $vars = array_merge($this->vars, $vars);
     $jsheadlinks = '';
     foreach ($this->jsLinks['head'] as $link) {
         $jsheadlinks .= '<script src="' . $link . '"></script>' . PHP_EOL;
     }
     $vars['jsheadlinks'] = $jsheadlinks;
     $jsbodylinks = '';
     foreach ($this->jsLinks['body'] as $link) {
         $jsbodylinks .= '<script src="' . $link . '"></script>' . PHP_EOL;
     }
     $vars['jsbodylinks'] = $jsbodylinks;
     $cssheadlinks = '';
     foreach ($this->cssLinks['head'] as $link) {
         $cssheadlinks .= '<link rel="stylesheet" href="' . $link . '"></link>' . PHP_EOL;
     }
     $vars['cssheadlinks'] = $cssheadlinks;
     $cssbodylinks = '';
     foreach ($this->cssLinks['body'] as $link) {
         $cssbodylinks .= '<link rel="stylesheet" href="' . $link . '"></link>' . PHP_EOL;
     }
     $vars['cssbodylinks'] = $cssbodylinks;
     if ($displayMessages) {
         $messages = array();
         $messages['success'] = $this->context->getSuccessMessages();
         $messages['info'] = $this->context->getInfoMessages();
         $messages['alert'] = $this->context->getAlertMessages();
         $messages['error'] = $this->context->getErrorMessages();
         $vars['messages'] = $messages;
     }
     $csscontext = [];
     $repository = $this->context->getCurrentRepository();
     if ($repository) {
         $csscontext[] = 'repository-' . strtolower($repository->getName());
         $record = $this->context->getCurrentRecord();
         if ($record) {
             $csscontext[] = 'contenttype-' . strtolower($record->getContentTypeName());
             $definition = $record->getContentTypeDefinition();
             if ($definition->hasSubtypes() && $record->getSubtype() != '') {
                 $csscontext[] = 'subtype-' . strtolower($record->getSubtype());
             }
             if ($definition->hasStatusList() && $record->getStatus() != '') {
                 $csscontext[] = 'status-' . strtolower($record->getStatus());
             }
         }
         $config = $this->context->getCurrentConfig();
         if ($config) {
             $csscontext[] = 'configtype-' . strtolower($config->getConfigTypeName());
         }
     }
     $vars['csscontext'] = join(' ', $csscontext);
     $event = new LayoutTemplateRenderEvent($app, $templateFilename, $vars);
     /** @var LayoutTemplateRenderEvent $event */
     $event = $app['dispatcher']->dispatch(Module::EVENT_LAYOUT_TEMPLATE_RENDER, $event);
     $templateFilename = $event->getTemplate();
     $vars = $event->getVars();
     return $this->twig->render($templateFilename, $vars);
 }
 public function getCurrentRepositoryAccessHash()
 {
     $repository = $this->context->getCurrentRepository();
     return $this->repos->getAccessHash($repository);
 }