谷歌关闭通过PHP与Externs

I am trying to use Google Closure but called through a php library.

This is the code I'm trying to work with

https://code.google.com/p/php-closure/

So far it seems to be working well. However I now need to use the "Externs" feature of Google Closure.

I have gone through the php library code but I am unsure on how to add this feature. The library appears to call the Google Closure online API code, so I assume to add the externs feature I just need to pass the correct string attached to the correct variable.

I won't post the entire library here as it would be hard to read, but the efforts I've made to incorporate this feature.

To begin I added the variable to the library

var $_srcs = array();
var $_mode = "WHITESPACE_ONLY";
var $_warning_level = "DEFAULT";
var $_use_closure_library = false;
var $_pretty_print = false;
var $_debug = true;
var $_cache_dir = "";
var $_code_url_prefix = "";
var $_extern_file = ""; //my new code

add to the hash function

function _getHash() {
return md5(implode(",", $this->_srcs) . "-" .
    $this->_mode . "-" .
    $this->_warning_level . "-" .
    $this->_use_closure_library . "-" .
    $this->_pretty_print . "-" .
    $this->_extern_file . "-" .     //here again
    $this->_debug);
}

add to get params list

function _getParamList() {
$params = array();
...
$params["warning_level"] = $this->_warning_level;
$params["extern_file"] = $this->_extern_file;      //again here
if ($this->_pretty_print) $params["formatting"] = "pretty_print";
if ($this->_use_closure_library) $params["use_closure_library"] = "true";
$params["output_info_1"] = "compiled_code";
$params["output_info_2"] = "statistics";
$params["output_info_3"] = "warnings";
$params["output_info_4"] = "errors";
return $params;
}

my add externs file function

function externs($file) {
  $this->_extern_file = $file;
  return $this;
}

then my user call

$c->add("js/my-app.js")
->add("js/popup.js")
->externs("js/externs.js")    //new code
->cacheDir("/tmp/js-cache/")
->write();

When trying to execute the code I get the same result as the original code. It appears the externs file that I'm trying to pass isn't being processed.

If anyone else is interested in this feature / library please feel free to post any ideas.

Thanks.

php
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐