/** * @return string */ protected function getRequirejsRcFile() { return $this->appPaths->getRootDir() . '/../.requirejsrc'; }
/** * Returns wkhtmltopdf options. * * @param string $uri * @param string $wkHtmlToPdfBin * * @return array */ public function getWkHtmlToPdfOptions($uri, $wkHtmlToPdfBin) { return ['dummy_pdf_url' => $this->appPaths->url('web') . '/pdf/empty.pdf', 'display_url' => $uri . '?do=display', 'download_url' => $uri . '?do=download', 'remote_url' => $uri . '?do=display', 'pluginDetect_PDFReader_url' => $this->appPaths->url('web') . '/pdf/PluginDetect_PDFReader.js', 'waiting_view_path' => $this->appPaths->absolute('web') . '/pdf/waiting-view.html', 'queue_db_path' => $this->appPaths->getRootDir() . '/pdf/queue.db', 'wkhtmltopdf_global' => ['binary' => $wkHtmlToPdfBin]]; }
/** * {@inheritdoc} */ public function createDocument(array $options = []) { $document = new HtmlDocument(); // used by Modernizr $document->element('html')->addClass('no-js'); // meta viewport $viewport = $this->params["meta_viewport"]; if (!empty($viewport)) { $meta = $document->element('viewport'); $meta->attr('content', $viewport); } // favicon $favicon = $document->element('favicon'); $favicon->enable($this->params["favicon_enable"]); $favicon->setBasePath($this->appPaths->url('web_theme') . '/favicons'); $favicon->setTileColor($this->params["favicon_tile_color"]); if (file_exists($this->appPaths->absolute('web_theme') . '/favicons/favicon.html')) { $favicon->setFaviconTemplate(file_get_contents($this->appPaths->absolute('web_theme') . '/favicons/favicon.html')); } // html lang $document->element('html')->attr('lang', $this->requestStack->getCurrentRequest()->getLocale()); // resources $utility = $this->getUtility($this->params); $utility->createResOnAdd($document, "javascript", "default"); $utility->createResOnAdd($document, "stylesheet", "default"); $document->resources("javascript")->chooseOnAdd("default"); $document->resources("stylesheet")->chooseOnAdd("default"); $configDir = $this->appPaths->getRootDir() . '/document'; if (file_exists($configDir . '/' . $this->theme->getName())) { $configDir .= '/' . $this->theme->getName(); } $locator = new FileLocator($configDir); $loader = $utility->createResourcesLoader($document, 'javascript', $locator, '/'); $loader->load('html_resources.yml', 'framework'); $loader->load('html_resources.yml', 'core'); $locator = new FileLocator($this->appPaths->absolute('private_theme')); $loader = $utility->createResourcesLoader($document, 'stylesheet', $locator, $this->appPaths->getThemePath() . '/src'); $loader->load('html_resources.yml', 'theme'); $loader = $utility->createResourcesLoader($document, 'javascript', $locator, $this->appPaths->getThemePath() . '/src'); $loader->load('html_resources.yml', 'theme'); // js initializer $jsloader = $this->getJsLoader(); $script = $document->element('script'); $twig = $this->twig; $env = $this->env; $document->setScriptOutput(function (JavaScriptResourceManager $manager, array $translations) use($jsloader, $script, $twig, $env) { $output = $jsloader->render('html'); if ($env === 'dev') { foreach ($jsloader->resources() as $resource) { if ($resource instanceof CombineResourceInterface && $resource->getCombineObject()->getException() instanceof \Exception) { throw $resource->getCombineObject()->getException(); } } } $output .= $twig->render('::head.html.twig', ["resources" => $manager->render('array'), "translations" => $translations]); if (!$script->isEmpty()) { $output .= '<script type="text/javascript">' . $script->render() . '</script>'; $script->update(function () { return ''; }); } return $output; }); // translations used in theme if (file_exists($this->appPaths->absolute("kernel_root") . '/theme/' . $this->appPaths->getThemeName() . '/translations.yml')) { $trans = $this->translator; $locator = new FileLocator($this->appPaths->absolute("kernel_root") . '/theme/' . $this->appPaths->getThemeName()); $loader = new TranslationLoader($locator, ['cache_dir' => $this->appPaths->absolute("kernel_cache") . "/vsymfo_document/translations", 'cache_refresh' => $this->env == "dev", 'document' => $document, 'trans_closure' => function ($text) use($trans) { return $trans->trans($text); }]); $loader->load('translations.yml'); } return $document; }