本文整理汇总了PHP中TempFSFile::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP TempFSFile::getPath方法的具体用法?PHP TempFSFile::getPath怎么用?PHP TempFSFile::getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TempFSFile
的用法示例。
在下文中一共展示了TempFSFile::getPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateAndSaveThumb
/**
* Generates a thumbnail according to the given parameters and saves it to storage
* @param TempFSFile $tmpFile Temporary file where the rendered thumbnail will be saved
* @param array $transformParams
* @param int $flags
* @return bool|MediaTransformOutput
*/
public function generateAndSaveThumb($tmpFile, $transformParams, $flags)
{
global $wgIgnoreImageErrors;
$stats = RequestContext::getMain()->getStats();
$handler = $this->getHandler();
$normalisedParams = $transformParams;
$handler->normaliseParams($this, $normalisedParams);
$thumbName = $this->thumbName($normalisedParams);
$thumbUrl = $this->getThumbUrl($thumbName);
$thumbPath = $this->getThumbPath($thumbName);
// final thumb path
$tmpThumbPath = $tmpFile->getPath();
if ($handler->supportsBucketing()) {
$this->generateBucketsIfNeeded($normalisedParams, $flags);
}
$starttime = microtime(true);
// Actually render the thumbnail...
$thumb = $handler->doTransform($this, $tmpThumbPath, $thumbUrl, $transformParams);
$tmpFile->bind($thumb);
// keep alive with $thumb
$statTiming = microtime(true) - $starttime;
$stats->timing('media.thumbnail.generate.transform', 1000 * $statTiming);
if (!$thumb) {
// bad params?
$thumb = false;
} elseif ($thumb->isError()) {
// transform error
/** @var $thumb MediaTransformError */
$this->lastError = $thumb->toText();
// Ignore errors if requested
if ($wgIgnoreImageErrors && !($flags & self::RENDER_NOW)) {
$thumb = $handler->getTransform($this, $tmpThumbPath, $thumbUrl, $transformParams);
}
} elseif ($this->repo && $thumb->hasFile() && !$thumb->fileIsSource()) {
// Copy the thumbnail from the file system into storage...
$starttime = microtime(true);
$disposition = $this->getThumbDisposition($thumbName);
$status = $this->repo->quickImport($tmpThumbPath, $thumbPath, $disposition);
if ($status->isOK()) {
$thumb->setStoragePath($thumbPath);
} else {
$thumb = $this->transformErrorOutput($thumbPath, $thumbUrl, $transformParams, $flags);
}
$statTiming = microtime(true) - $starttime;
$stats->timing('media.thumbnail.generate.store', 1000 * $statTiming);
// Give extensions a chance to do something with this thumbnail...
Hooks::run('FileTransformed', array($this, $thumb, $tmpThumbPath, $thumbPath));
}
return $thumb;
}
示例2: generateAndSaveThumb
/**
* Generates a thumbnail according to the given parameters and saves it to storage
* @param TempFSFile $tmpFile Temporary file where the rendered thumbnail will be saved
* @param array $transformParams
* @param int $flags
* @return bool|MediaTransformOutput
*/
public function generateAndSaveThumb($tmpFile, $transformParams, $flags)
{
global $wgUseSquid, $wgIgnoreImageErrors;
$handler = $this->getHandler();
$normalisedParams = $transformParams;
$handler->normaliseParams($this, $normalisedParams);
$thumbName = $this->thumbName($normalisedParams);
$thumbUrl = $this->getThumbUrl($thumbName);
$thumbPath = $this->getThumbPath($thumbName);
// final thumb path
$tmpThumbPath = $tmpFile->getPath();
if ($handler->supportsBucketing()) {
$this->generateBucketsIfNeeded($normalisedParams, $flags);
}
// Actually render the thumbnail...
$thumb = $handler->doTransform($this, $tmpThumbPath, $thumbUrl, $transformParams);
$tmpFile->bind($thumb);
// keep alive with $thumb
if (!$thumb) {
// bad params?
$thumb = false;
} elseif ($thumb->isError()) {
// transform error
$this->lastError = $thumb->toText();
// Ignore errors if requested
if ($wgIgnoreImageErrors && !($flags & self::RENDER_NOW)) {
$thumb = $handler->getTransform($this, $tmpThumbPath, $thumbUrl, $transformParams);
}
} elseif ($this->repo && $thumb->hasFile() && !$thumb->fileIsSource()) {
// Copy the thumbnail from the file system into storage...
$disposition = $this->getThumbDisposition($thumbName);
$status = $this->repo->quickImport($tmpThumbPath, $thumbPath, $disposition);
if ($status->isOK()) {
$thumb->setStoragePath($thumbPath);
} else {
$thumb = $this->transformErrorOutput($thumbPath, $thumbUrl, $transformParams, $flags);
}
// Give extensions a chance to do something with this thumbnail...
Hooks::run('FileTransformed', array($this, $thumb, $tmpThumbPath, $thumbPath));
}
// Purge. Useful in the event of Core -> Squid connection failure or squid
// purge collisions from elsewhere during failure. Don't keep triggering for
// "thumbs" which have the main image URL though (bug 13776)
if ($wgUseSquid) {
if (!$thumb || $thumb->isError() || $thumb->getUrl() != $this->getURL()) {
SquidUpdate::purge(array($thumbUrl));
}
}
return $thumb;
}