本文整理汇总了PHP中OC\Files\Cache\Cache::move方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::move方法的具体用法?PHP Cache::move怎么用?PHP Cache::move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Files\Cache\Cache
的用法示例。
在下文中一共展示了Cache::move方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renameFromStorage
/**
* Rename a file or folder in the cache and update the size, etag and mtime of the parent folders
*
* @param IStorage $sourceStorage
* @param string $source
* @param string $target
*/
public function renameFromStorage(IStorage $sourceStorage, $source, $target)
{
if (!$this->enabled or Scanner::isPartialFile($source) or Scanner::isPartialFile($target)) {
return;
}
$time = time();
$sourceCache = $sourceStorage->getCache();
$sourceUpdater = $sourceStorage->getUpdater();
$sourcePropagator = $sourceStorage->getPropagator();
if ($sourceCache->inCache($source)) {
if ($this->cache->inCache($target)) {
$this->cache->remove($target);
}
if ($sourceStorage === $this->storage) {
$this->cache->move($source, $target);
} else {
$this->cache->moveFromCache($sourceCache, $source, $target);
}
}
if (pathinfo($source, PATHINFO_EXTENSION) !== pathinfo($target, PATHINFO_EXTENSION)) {
// handle mime type change
$mimeType = $this->storage->getMimeType($target);
$fileId = $this->cache->getId($target);
$this->cache->update($fileId, ['mimetype' => $mimeType]);
}
$sourceCache->correctFolderSize($source);
$this->cache->correctFolderSize($target);
if ($sourceUpdater instanceof Updater) {
$sourceUpdater->correctParentStorageMtime($source);
}
$this->correctParentStorageMtime($target);
$this->updateStorageMTimeOnly($target);
$sourcePropagator->propagateChange($source, $time);
$this->propagator->propagateChange($target, $time);
}
示例2: testMove
function testMove() {
$file1 = 'folder';
$file2 = 'folder/bar';
$file3 = 'folder/foo';
$file4 = 'folder/foo/1';
$file5 = 'folder/foo/2';
$data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/bar');
$folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory');
$this->cache->put($file1, $folderData);
$this->cache->put($file2, $folderData);
$this->cache->put($file3, $folderData);
$this->cache->put($file4, $data);
$this->cache->put($file5, $data);
/* simulate a second user with a different storage id but the same folder structure */
$this->cache2->put($file1, $folderData);
$this->cache2->put($file2, $folderData);
$this->cache2->put($file3, $folderData);
$this->cache2->put($file4, $data);
$this->cache2->put($file5, $data);
$this->cache->move('folder/foo', 'folder/foobar');
$this->assertFalse($this->cache->inCache('folder/foo'));
$this->assertFalse($this->cache->inCache('folder/foo/1'));
$this->assertFalse($this->cache->inCache('folder/foo/2'));
$this->assertTrue($this->cache->inCache('folder/bar'));
$this->assertTrue($this->cache->inCache('folder/foobar'));
$this->assertTrue($this->cache->inCache('folder/foobar/1'));
$this->assertTrue($this->cache->inCache('folder/foobar/2'));
/* the folder structure of the second user must not change! */
$this->assertTrue($this->cache2->inCache('folder/bar'));
$this->assertTrue($this->cache2->inCache('folder/foo'));
$this->assertTrue($this->cache2->inCache('folder/foo/1'));
$this->assertTrue($this->cache2->inCache('folder/foo/2'));
$this->assertFalse($this->cache2->inCache('folder/foobar'));
$this->assertFalse($this->cache2->inCache('folder/foobar/1'));
$this->assertFalse($this->cache2->inCache('folder/foobar/2'));
}
示例3: testEscaping
/**
* @param string $name
* @dataProvider escapingProvider
*/
public function testEscaping($name)
{
$data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain');
$this->cache->put($name, $data);
$this->assertTrue($this->cache->inCache($name));
$retrievedData = $this->cache->get($name);
foreach ($data as $key => $value) {
$this->assertEquals($value, $retrievedData[$key]);
}
$this->cache->move($name, $name . 'asd');
$this->assertFalse($this->cache->inCache($name));
$this->assertTrue($this->cache->inCache($name . 'asd'));
$this->cache->remove($name . 'asd');
$this->assertFalse($this->cache->inCache($name . 'asd'));
$folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory');
$this->cache->put($name, $folderData);
$this->cache->put('other', $folderData);
$childs = ['asd', 'bar', 'foo', 'sub/folder'];
$this->cache->put($name . '/sub', $folderData);
$this->cache->put('other/sub', $folderData);
foreach ($childs as $child) {
$this->cache->put($name . '/' . $child, $data);
$this->cache->put('other/' . $child, $data);
$this->assertTrue($this->cache->inCache($name . '/' . $child));
}
$this->cache->move($name, $name . 'asd');
foreach ($childs as $child) {
$this->assertTrue($this->cache->inCache($name . 'asd/' . $child));
$this->assertTrue($this->cache->inCache('other/' . $child));
}
foreach ($childs as $child) {
$this->cache->remove($name . 'asd/' . $child);
$this->assertFalse($this->cache->inCache($name . 'asd/' . $child));
$this->assertTrue($this->cache->inCache('other/' . $child));
}
}
示例4: move
/**
* Move a file or folder in the cache
*
* @param string $source
* @param string $target
*/
public function move($source, $target)
{
$this->cache->move($source, $target);
}