protected function _query($content, $args = array())
{
if (!extension_loaded('curl')) {
throw new \Exception('Missing the `curl` extension.');
}
$args = array_merge($this->_defaults, $args);
if (!empty($this->_settings['level'])) {
$args['compilation_level'] = $this->_settings['level'];
}
foreach ($this->_settings as $key => $val) {
if (in_array($key, $this->_params)) {
$args[$key] = $val;
}
}
$ch = curl_init();
curl_setopt_array($ch, array(CURLOPT_URL => 'http://closure-compiler.appspot.com/compile', CURLOPT_POST => 1, CURLOPT_POSTFIELDS => 'js_code=' . urlencode($content) . '&' . http_build_query($args), CURLOPT_RETURNTRANSFER => 1, CURLOPT_HEADER => 0, CURLOPT_FOLLOWLOCATION => 0));
$output = curl_exec($ch);
if (false === $output) {
throw new \Exception('Curl error: ' . curl_error($ch));
}
curl_close($ch);
return $output;
}