/**
  * @param boolean $useRequirejsRc
  * @param string $jsonFilePath
  * @param array $options
  * @param array $extend
  *
  * @return string
  */
 protected function generateConfig($useRequirejsRc, $jsonFilePath, array $options, array $extend = [])
 {
     $jsonFile = $this->getSrcFileName($jsonFilePath);
     if (!file_exists($jsonFile)) {
         throw new \UnexpectedValueException('Not found file: ' . $jsonFile);
     }
     $json = json_decode(file_get_contents($jsonFile), true);
     if (!is_array($json)) {
         throw new \UnexpectedValueException('File ' . $jsonFile . ' is invalid.');
     }
     if ($useRequirejsRc) {
         $rcFile = $this->getRequirejsRcFile();
         if (!file_exists($rcFile)) {
             throw new \UnexpectedValueException('Not found file: ' . $rcFile);
         }
         $rcData = json_decode(file_get_contents($rcFile), true);
         if (!is_array($rcData)) {
             throw new \UnexpectedValueException('File ' . $rcFile . ' is invalid.');
         }
     } else {
         $rcData = [];
     }
     $params = $this->resolver->resolve($options);
     $basePath = $this->appPaths->getBasePath();
     $defaults = ['timeout' => (int) $this->params['resources_loading_timeout'], 'res' => $params['resources'], 'translations' => $params['translations'], 'locale' => $this->request->getCurrentRequest()->getLocale(), 'theme_name' => $this->theme->getName(), 'path' => ['base' => $basePath, 'theme' => $this->appPaths->url('web_theme'), 'resources' => $this->appPaths->url('web_resources'), 'lib' => $this->appPaths->url('web_resources') . '/lib', 'cdn_javascript' => $this->params['cdn_enable'] ? $this->params['cdn_javascript'] : '', 'cdn_css' => $this->params['cdn_enable'] ? $this->params['cdn_css'] : '', 'cdn_image' => $this->params['cdn_enable'] ? $this->params['cdn_image'] : ''], 'requirejs' => ['baseUrl' => $basePath . '/js']];
     $config = array_merge_recursive($defaults, ['requirejs' => $rcData], $json, $extend);
     return json_encode($config, JSON_HEX_QUOT | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS);
 }
 /**
  * @return JavaScriptResourceManager
  */
 public function getJsLoader()
 {
     $utility = $this->getUtility($this->params, ['cache_db_dir' => $this->appPaths->absolute('kernel_cache') . '/../document_jsloader/loader', 'web_cache_dir' => $this->appPaths->absolute('web_cache'), 'web_cache_url' => $this->appPaths->url('web_cache')]);
     $doc = new HtmlDocument();
     $utility->createResOnAdd($doc, "javascript", "default");
     $doc->resources("javascript")->chooseOnAdd("default");
     $locator = new FileLocator($this->appPaths->absolute("kernel_root") . '/document');
     $loader = $utility->createResourcesLoader($doc, 'javascript', $locator, '/');
     $loader->load('jsloader.yml', 'jsloader');
     return $doc->resources("javascript");
 }
 /**
  * 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]];
 }