本文整理汇总了PHP中FileRepo::getLocalReference方法的典型用法代码示例。如果您正苦于以下问题:PHP FileRepo::getLocalReference方法的具体用法?PHP FileRepo::getLocalReference怎么用?PHP FileRepo::getLocalReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileRepo
的用法示例。
在下文中一共展示了FileRepo::getLocalReference方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLocalRefPath
/**
* Get an FS copy or original of this file and return the path.
* Returns false on failure. Callers must not alter the file.
* Temporary files are cleared automatically.
*
* @return string|false
*/
public function getLocalRefPath()
{
$this->assertRepoDefined();
if (!isset($this->fsFile)) {
$this->fsFile = $this->repo->getLocalReference($this->getPath());
if (!$this->fsFile) {
$this->fsFile = false;
// null => false; cache negative hits
}
}
return $this->fsFile ? $this->fsFile->getPath() : false;
}
示例2: getThumbnailSource
/**
* Returns the most appropriate source image for the thumbnail, given a target thumbnail size
* @param array $params
* @return array Source path and width/height of the source
*/
public function getThumbnailSource($params)
{
if ($this->repo && $this->getHandler()->supportsBucketing() && isset($params['physicalWidth']) && ($bucket = $this->getThumbnailBucket($params['physicalWidth']))) {
if ($this->getWidth() != 0) {
$bucketHeight = round($this->getHeight() * ($bucket / $this->getWidth()));
} else {
$bucketHeight = 0;
}
// Try to avoid reading from storage if the file was generated by this script
if (isset($this->tmpBucketedThumbCache[$bucket])) {
$tmpPath = $this->tmpBucketedThumbCache[$bucket];
if (file_exists($tmpPath)) {
return array('path' => $tmpPath, 'width' => $bucket, 'height' => $bucketHeight);
}
}
$bucketPath = $this->getBucketThumbPath($bucket);
if ($this->repo->fileExists($bucketPath)) {
$fsFile = $this->repo->getLocalReference($bucketPath);
if ($fsFile) {
return array('path' => $fsFile->getPath(), 'width' => $bucket, 'height' => $bucketHeight);
}
}
}
// Thumbnailing a very large file could result in network saturation if
// everyone does it at once.
if ($this->getSize() >= 10000000.0) {
// 10MB
$that = $this;
$work = new PoolCounterWorkViaCallback('GetLocalFileCopy', sha1($this->getName()), array('doWork' => function () use($that) {
return $that->getLocalRefPath();
}));
$srcPath = $work->execute();
} else {
$srcPath = $this->getLocalRefPath();
}
// Original file
return array('path' => $srcPath, 'width' => $this->getWidth(), 'height' => $this->getHeight());
}
示例3: getThumbnailSource
/**
* Returns the most appropriate source image for the thumbnail, given a target thumbnail size
* @param array $params
* @return array Source path and width/height of the source
*/
public function getThumbnailSource($params)
{
if ($this->repo && $this->getHandler()->supportsBucketing() && isset($params['physicalWidth']) && ($bucket = $this->getThumbnailBucket($params['physicalWidth']))) {
if ($this->getWidth() != 0) {
$bucketHeight = round($this->getHeight() * ($bucket / $this->getWidth()));
} else {
$bucketHeight = 0;
}
// Try to avoid reading from storage if the file was generated by this script
if (isset($this->tmpBucketedThumbCache[$bucket])) {
$tmpPath = $this->tmpBucketedThumbCache[$bucket];
if (file_exists($tmpPath)) {
return array('path' => $tmpPath, 'width' => $bucket, 'height' => $bucketHeight);
}
}
$bucketPath = $this->getBucketThumbPath($bucket);
if ($this->repo->fileExists($bucketPath)) {
$fsFile = $this->repo->getLocalReference($bucketPath);
if ($fsFile) {
return array('path' => $fsFile->getPath(), 'width' => $bucket, 'height' => $bucketHeight);
}
}
}
// Original file
return array('path' => $this->getLocalRefPath(), 'width' => $this->getWidth(), 'height' => $this->getHeight());
}