resolvePublicWebPath() public method

('images/test.png') => images/webtest.png ('routepath/do-something') => routepath/do-something ('routepath/do-something') => app_dev.php/routepath/do-something ('http://external.tld/style.css') => http://external.tld/style.css
public resolvePublicWebPath ( string $path ) : string
$path string
return string
Ejemplo n.º 1
0
 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>');
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * @param array $files
  * @param string $includePath The directory where to compressed css is. with trailing slash!
  *
  * @return string
  */
 public function compressCss(array $files, $includePath = '')
 {
     $webDir = realpath($this->jarves->getRootDir() . '/../web') . '/';
     $content = '';
     foreach ($files as $assetPath) {
         $cssFile = $this->jarves->resolvePublicWebPath($assetPath);
         //bundles/jarves/css/style.css
         $cssDir = dirname($cssFile) . '/';
         //admin/css/...
         $cssDir = str_repeat('../', substr_count($includePath, '/')) . $cssDir;
         $content .= "\n\n/* file: {$assetPath} */\n\n";
         if (file_exists($file = $webDir . $cssFile)) {
             $h = fopen($file, "r");
             if ($h) {
                 while (!feof($h) && $h) {
                     $buffer = fgets($h, 4096);
                     $buffer = preg_replace('/@import \'(?!.*:\\/\\/)([^\\/].*)\'/', '@import \'' . $cssDir . '$1\'', $buffer);
                     $buffer = preg_replace('/@import "(?!.*:\\/\\/)([^\\/].*)"/', '@import "' . $cssDir . '$1"', $buffer);
                     $buffer = preg_replace('/url\\(\'(?!.*:\\/\\/)([^\\/][^\\)]*)\'\\)/', 'url(\'' . $cssDir . '$1\')', $buffer);
                     $buffer = preg_replace('/url\\(\\"(?!.*:\\/\\/)([^\\/][^\\)]*)\\"\\)/', 'url(\\"' . $cssDir . '$1\\")', $buffer);
                     $buffer = preg_replace('/url\\((?!.*data:image)(?!.*:\\/\\/)([^\\/\'].*)\\)/', 'url(' . $cssDir . '$1)', $buffer);
                     $buffer = str_replace(array('  ', '    ', "\t", "\n", "\r"), '', $buffer);
                     $buffer = str_replace(': ', ':', $buffer);
                     $content .= $buffer;
                 }
                 fclose($h);
             }
         } else {
             $content .= '/* => `' . $cssFile . '` not exist. */';
         }
     }
     return $content;
 }
Ejemplo n.º 3
0
 public function getFaviconPath()
 {
     return $this->jarves->resolvePublicWebPath($this->getFavicon());
 }