Jarves\Jarves::resolvePublicWebPath PHP 메소드

resolvePublicWebPath() 공개 메소드

('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
리턴 string
    public function resolvePublicWebPath($path)
    {
        //if its a external path?
        if (strpos($path, '://') !== false) {
            return $path;
        }
        $webDir = realpath($this->rootDir . '/../web') . '/';
        if ($path && '@' === $path[0]) {
            try {
                $path = $this->resolveWebPath($path);
                $path = substr($path, strpos($path, '/') + 1);
            } catch (BundleNotFoundException $e) {
            }
        }
        if (file_exists($webDir . $path)) {
            return $path;
        }
        if ($this->requestStack->getMasterRequest()) {
            //do we need to add app_dev.php/ or something?
            $prefix = substr($this->requestStack->getMasterRequest()->getBaseUrl(), strlen($this->requestStack->getMasterRequest()->getBasePath()));
            if (false !== $prefix) {
                if ($prefix && ($prefix = substr($prefix, 1))) {
                    $path = $prefix . '/' . $path;
                }
            }
        }
        return $path;
    }

Usage Example

예제 #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>');
         }
     }
 }
All Usage Examples Of Jarves\Jarves::resolvePublicWebPath