('@JarvesBundle/admin/js/test.js') => /var/www/jarves/src/Jarves/Resources/public/admin/js/test.js
public resolveInternalPublicPath ( string $path ) : mixed | ||
$path | string | |
return | mixed |
public function appendAngularTemplates() { $response = $this->pageStack->getPageResponse(); foreach ($this->jarves->getConfigs() as $bundle) { $templates = $bundle->getAdminAngularTemplatesInfo(); foreach ($templates as $template) { $publicPath = $this->jarves->resolvePublicWebPath($template->getPath()); $localPath = $this->jarves->resolveInternalPublicPath($template->getPath()); $content = file_get_contents($localPath); $content = str_replace('</script>', '', $content); $response->addHeader('<script type="text/ng-template" id="' . $publicPath . '">' . $content . '</script>'); } } }
/** * This is a try to increase initial loading performance, but I wasn't lucky. * * @ApiDoc( * section="Backend", * description="Prints all typscript modules combined" * ) * * @Rest\Get("/admin/backend/typescript-modules.ts") * * @return string CCS */ public function loadTypescriptModules() { $newestMTime = 0; $jsContent = ''; foreach ($this->jarves->getConfigs() as $bundleConfig) { $path = $bundleConfig->getBundleClass()->getPath(); $assetInfos = $bundleConfig->getAdminPreloadTypescriptModulesInfo(); foreach ($assetInfos as $assetInfo) { $localPath = $this->jarves->resolveInternalPublicPath($assetInfo->getPath()); $mtime = filemtime($localPath); $newestMTime = max($newestMTime, $mtime); $content = file_get_contents($localPath); $moduleName = sprintf('./bundles/%s/%s', $bundleConfig->getName(), Tools::getRelativePath($localPath, $path . '/Resources/public/')); $jsContent .= "\n/* ts file {$moduleName} */\ndeclare module \"{$moduleName}\" {\n{$content}\n};\n"; } } $ifModifiedSince = $this->pageStack->getRequest()->headers->get('If-Modified-Since'); if (isset($ifModifiedSince) && strtotime($ifModifiedSince) == $newestMTime) { // Client's cache IS current, so we just respond '304 Not Modified'. $response = new Response(); $response->setStatusCode(304); $response->headers->set('Last-Modified', gmdate('D, d M Y H:i:s', $newestMTime) . ' GMT'); return $response; } $expires = 60 * 60 * 24 * 14; //2 weeks $response = new Response(); $response->headers->set('Content-Type', 'application/javascript'); $response->headers->set('Pragma', 'public'); $response->headers->set('Cache-Control', 'max-age=' . $expires); $response->headers->set('Expires', gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); // $content = implode($files); $response->setContent($jsContent); return $response; }