Created
          February 19, 2014 13:19 
        
      - 
      
- 
        Save gmorel/9091805 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public function computeAssetUrl($assetType, $params, \Smarty_Internal_Template $template) | |
| { | |
| $file = $params['file']; | |
| $assetOrigin = isset($params['source']) ? $params['source'] : "0"; | |
| $filters = isset($params['filters']) ? $params['filters'] : ''; | |
| $debug = isset($params['debug']) ? trim(strtolower($params['debug'])) == 'true' : false; | |
| $webAssetTemplate = isset($params['template']) ? $params['template'] : false; | |
| /* we trick here relative thinking for file attribute */ | |
| $file = ltrim($file, '/'); | |
| while (substr($file, 0, 3) == '../') { | |
| $file = substr($file, 3); | |
| } | |
| $smartyParser = $template->smarty; | |
| $templateDefinition = $smartyParser->getTemplateDefinition(); | |
| $templateDirectories = $smartyParser->getTemplateDirectories($templateDefinition->getType()); | |
| if (! isset($templateDirectories[$templateDefinition->getName()][$assetOrigin])) { | |
| throw new \Exception("Failed to get real path of '/".dirname($file)."'"); | |
| } | |
| $assetSource = $templateDirectories[$templateDefinition->getName()][$assetOrigin]; | |
| if ($webAssetTemplate) { | |
| $assetSource = str_replace($templateDefinition->getName(), $webAssetTemplate, $assetSource); | |
| } | |
| $url = $this->assetsManager->processAsset( | |
| $assetSource . DS . $file, | |
| $assetSource . DS . self::$assetsDirectory, | |
| $this->web_root . $this->path_relative_to_web_root, | |
| $templateDefinition->getPath(), | |
| $assetOrigin, | |
| URL::getInstance()->absoluteUrl($this->path_relative_to_web_root, null, URL::PATH_TO_FILE /* path only */), | |
| $assetType, | |
| $filters, | |
| $debug | |
| ); | |
| return $url; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment