本文整理汇总了PHP中AssetsManager::getRequestDetails方法的典型用法代码示例。如果您正苦于以下问题:PHP AssetsManager::getRequestDetails方法的具体用法?PHP AssetsManager::getRequestDetails怎么用?PHP AssetsManager::getRequestDetails使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssetsManager
的用法示例。
在下文中一共展示了AssetsManager::getRequestDetails方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sassProcessing
private function sassProcessing()
{
global $IP, $wgSassExecutable, $wgDevelEnvironment;
wfProfileIn(__METHOD__);
$tempDir = sys_get_temp_dir();
//replace \ to / is needed because escapeshellcmd() replace \ into spaces (?!!)
$tempOutFile = str_replace('\\', '/', tempnam($tempDir, 'Sass'));
$tempDir = str_replace('\\', '/', $tempDir);
$params = urldecode(http_build_query($this->mParams, '', ' '));
$cmd = "{$wgSassExecutable} {$IP}/{$this->mOid} {$tempOutFile} --cache-location {$tempDir}/sass -r {$IP}/extensions/wikia/SASS/wikia_sass.rb {$params}";
$escapedCmd = escapeshellcmd($cmd) . " 2>&1";
$sassResult = shell_exec($escapedCmd);
if ($sassResult != '') {
Wikia::log(__METHOD__, false, "commandline error: " . $sassResult . " -- Full commandline was: {$escapedCmd}", true);
Wikia::log(__METHOD__, false, "Full commandline was: {$escapedCmd}", true);
Wikia::log(__METHOD__, false, AssetsManager::getRequestDetails(), true);
if (file_exists($tempOutFile)) {
unlink($tempOutFile);
}
if (!empty($wgDevelEnvironment)) {
$exceptionMsg = "Problem with SASS processing: {$sassResult}";
} else {
$exceptionMsg = 'Problem with SASS processing. Check the PHP error log for more info.';
}
throw new Exception("/* {$exceptionMsg} */");
}
$this->mContent = file_get_contents($tempOutFile);
unlink($tempOutFile);
wfProfileOut(__METHOD__);
}
示例2: __construct
public function __construct(WebRequest $request)
{
parent::__construct($request);
global $IP;
if (strpos($this->mOid, '..') !== false) {
throw new Exception('File path must not contain \'..\'.');
}
if (endsWith($this->mOid, '.js', false)) {
$this->mContentType = AssetsManager::TYPE_JS;
} else {
if (endsWith($this->mOid, '.css', false)) {
$this->mContentType = AssetsManager::TYPE_CSS;
} else {
throw new Exception('Requested file must be .css or .js.');
}
}
$filePath = $IP . '/' . $this->mOid;
if (file_exists($filePath)) {
$this->mContent = file_get_contents($filePath);
} else {
$requestDetails = AssetsManager::getRequestDetails();
Wikia::log(__METHOD__, false, "file '{$filePath}' doesn't exist ({$requestDetails})", true);
throw new Exception('File does not exist');
}
}
示例3: __construct
function __construct($message)
{
// add referer and user agent info to the exception message
$details = AssetsManager::getRequestDetails();
$message .= " ({$details})";
parent::__construct($message);
}
示例4: serve
public static function serve(WebRequest $request)
{
try {
switch ($request->getText('type')) {
case 'one':
$builder = new AssetsManagerOneBuilder($request);
break;
case 'group':
$builder = new AssetsManagerGroupBuilder($request);
break;
case 'groups':
$builder = new AssetsManagerGroupsBuilder($request);
break;
case 'sass':
$builder = new AssetsManagerSassBuilder($request);
break;
default:
Wikia::log(__METHOD__, false, "Unknown type: {$_SERVER['REQUEST_URI']}", true);
Wikia::log(__METHOD__, false, AssetsManager::getRequestDetails(), true);
throw new Exception('Unknown type.');
}
} catch (Exception $e) {
header('HTTP/1.1 404 Not Found');
echo $e->getMessage();
return;
}
$headers = array();
if ($builder->getContentType()) {
$headers['Content-Type'] = $builder->getContentType();
}
// BugId:31327
$headers['Vary'] = $builder->getVary();
$cacheDuration = $builder->getCacheDuration();
if ($cacheDuration > 0) {
$headers['Expires'] = gmdate('D, d M Y H:i:s \\G\\M\\T', strtotime($cacheDuration . ' seconds'));
$headers['X-Pass-Cache-Control'] = $builder->getCacheMode() . ', max-age=' . $cacheDuration;
$headers['Cache-Control'] = $builder->getCacheMode() . ', max-age=' . $cacheDuration;
}
$headers['Last-Modified'] = gmdate('D, d M Y H:i:s \\G\\M\\T');
foreach ($headers as $k => $v) {
header($k . ': ' . $v);
}
echo $builder->getContent();
}
示例5: getGroupAssets
/**
* Returns assets array for particular group. If group does not exists in config then returns empty array
*
* @author Inez Korczyński <korczynski@gmail.com>
*/
protected function getGroupAssets($groupName)
{
$this->load();
if (is_string($groupName) && isset($this->mConfig[$groupName])) {
return $this->mConfig[$groupName]['assets'];
} else {
$requestDetails = AssetsManager::getRequestDetails();
Wikia::log(__METHOD__, false, "group '{$groupName}' doesn't exist ({$requestDetails})", true);
return array();
}
}
示例6: serve
public static function serve(WebRequest $request)
{
$type = $request->getText('type');
try {
switch ($type) {
case 'one':
$builder = new AssetsManagerOneBuilder($request);
break;
case 'group':
$builder = new AssetsManagerGroupBuilder($request);
break;
case 'groups':
$builder = new AssetsManagerGroupsBuilder($request);
break;
case 'sass':
$builder = new AssetsManagerSassBuilder($request);
break;
case 'sasses':
$builder = new AssetsManagerSassesBuilder($request);
break;
default:
Wikia::log(__METHOD__, false, "Unknown type: {$_SERVER['REQUEST_URI']}", true);
Wikia::log(__METHOD__, false, AssetsManager::getRequestDetails(), true);
throw new Exception('Unknown type.');
}
} catch (Exception $e) {
header('HTTP/1.1 404 Not Found');
echo $e->getMessage();
return;
}
// do not log illegal request type (one/group/groups/sass supported only) - not to pollute
// logs
Transaction::setEntryPoint(Transaction::ENTRY_POINT_ASSETS_MANAGER);
if (function_exists('newrelic_disable_autorum')) {
newrelic_disable_autorum();
}
$headers = array();
if ($builder->getContentType()) {
$headers['Content-Type'] = $builder->getContentType();
}
// BugId:31327
$headers['Vary'] = $builder->getVary();
$cacheDuration = $builder->getCacheDuration();
// render the response
try {
$content = $builder->getContent();
} catch (Exception $e) {
// return HTTP 503 in case of SASS processing error (BAC-592)
// Varnish will cache such response for 5 seconds
header('HTTP/1.1 503');
// log exception messages
\Wikia\Logger\WikiaLogger::instance()->error('AssetsManagerServer::serve failed', ['type' => $type, 'exception' => $e]);
// emit full message on devboxes only
global $wgDevelEnvironment;
$content = !empty($wgDevelEnvironment) ? $msg = $e->getMessage() : '/* SASS processing failed! */';
}
if ($cacheDuration > 0) {
$headers['Cache-Control'] = 'public, max-age=' . $cacheDuration['server'];
$headers['X-Pass-Cache-Control'] = 'public, max-age=' . $cacheDuration['client'];
}
$headers['Last-Modified'] = gmdate('D, d M Y H:i:s \\G\\M\\T');
// Add X-Served-By and X-Backend-Response-Time response headers to MediaWiki pages
// See BAC-550 for details
// @macbre
global $wgRequestTime;
$headers['X-Served-By'] = wfHostname();
$headers['X-Backend-Response-Time'] = round(microtime(true) - $wgRequestTime, 3);
foreach ($headers as $k => $v) {
header($k . ': ' . $v);
}
echo $content;
}