本文整理汇总了PHP中FileBackend::doOperation方法的典型用法代码示例。如果您正苦于以下问题:PHP FileBackend::doOperation方法的具体用法?PHP FileBackend::doOperation怎么用?PHP FileBackend::doOperation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileBackend
的用法示例。
在下文中一共展示了FileBackend::doOperation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: freeTemp
/**
* Remove a temporary file or mark it for garbage collection
*
* @param $virtualUrl String: the virtual URL returned by FileRepo::storeTemp()
* @return Boolean: true on success, false on failure
*/
public function freeTemp($virtualUrl)
{
$temp = "mwrepo://{$this->name}/temp";
if (substr($virtualUrl, 0, strlen($temp)) != $temp) {
wfDebug(__METHOD__ . ": Invalid temp virtual URL\n");
return false;
}
$path = $this->resolveVirtualUrl($virtualUrl);
$op = array('op' => 'delete', 'src' => $path);
$status = $this->backend->doOperation($op);
return $status->isOK();
}
示例2: doTestGetDirectoryList
//.........这里部分代码省略.........
sort($expected);
// Actual listing (no trailing slash)
$list = array();
$iter = $this->backend->getTopDirectoryList(array('dir' => "{$base}/unittest-cont1"));
foreach ($iter as $file) {
$list[] = $file;
}
sort($list);
$this->assertEquals($expected, $list, "Correct top dir listing ({$backendName}).");
// Expected listing
$expected = array("subdir1", "subdir2", "subdir3", "subdir4");
sort($expected);
// Actual listing (no trailing slash)
$list = array();
$iter = $this->backend->getTopDirectoryList(array('dir' => "{$base}/unittest-cont1/e"));
foreach ($iter as $file) {
$list[] = $file;
}
sort($list);
$this->assertEquals($expected, $list, "Correct top dir listing ({$backendName}).");
// Actual listing (with trailing slash)
$list = array();
$iter = $this->backend->getTopDirectoryList(array('dir' => "{$base}/unittest-cont1/e/"));
foreach ($iter as $file) {
$list[] = $file;
}
sort($list);
$this->assertEquals($expected, $list, "Correct top dir listing ({$backendName}).");
// Expected listing
$expected = array("subdir");
sort($expected);
// Actual listing (no trailing slash)
$list = array();
$iter = $this->backend->getTopDirectoryList(array('dir' => "{$base}/unittest-cont1/e/subdir2"));
foreach ($iter as $file) {
$list[] = $file;
}
sort($list);
$this->assertEquals($expected, $list, "Correct top dir listing ({$backendName}).");
// Actual listing (with trailing slash)
$list = array();
$iter = $this->backend->getTopDirectoryList(array('dir' => "{$base}/unittest-cont1/e/subdir2/"));
foreach ($iter as $file) {
$list[] = $file;
}
sort($list);
$this->assertEquals($expected, $list, "Correct top dir listing ({$backendName}).");
// Actual listing (using iterator second time)
$list = array();
foreach ($iter as $file) {
$list[] = $file;
}
sort($list);
$this->assertEquals($expected, $list, "Correct top dir listing ({$backendName}), second iteration.");
// Expected listing (recursive)
$expected = array("e", "e/subdir1", "e/subdir2", "e/subdir3", "e/subdir4", "e/subdir2/subdir", "e/subdir3/subdir", "e/subdir4/subdir", "e/subdir4/subdir/sub");
sort($expected);
// Actual listing (recursive)
$list = array();
$iter = $this->backend->getDirectoryList(array('dir' => "{$base}/unittest-cont1/"));
foreach ($iter as $file) {
$list[] = $file;
}
sort($list);
$this->assertEquals($expected, $list, "Correct dir listing ({$backendName}).");
// Expected listing (recursive)
$expected = array("subdir", "subdir/sub");
sort($expected);
// Actual listing (recursive)
$list = array();
$iter = $this->backend->getDirectoryList(array('dir' => "{$base}/unittest-cont1/e/subdir4"));
foreach ($iter as $file) {
$list[] = $file;
}
sort($list);
$this->assertEquals($expected, $list, "Correct dir listing ({$backendName}).");
// Actual listing (recursive, second time)
$list = array();
foreach ($iter as $file) {
$list[] = $file;
}
sort($list);
$this->assertEquals($expected, $list, "Correct dir listing ({$backendName}).");
$iter = $this->backend->getDirectoryList(array('dir' => "{$base}/unittest-cont1/e/subdir1"));
$items = $this->listToArray($iter);
$this->assertEquals(array(), $items, "Directory listing is empty.");
foreach ($files as $file) {
// clean up
$this->backend->doOperation(array('op' => 'delete', 'src' => $file));
}
$iter = $this->backend->getDirectoryList(array('dir' => "{$base}/unittest-cont1/not/exists"));
foreach ($iter as $file) {
// no errors
}
$items = $this->listToArray($iter);
$this->assertEquals(array(), $items, "Directory listing is empty.");
$iter = $this->backend->getDirectoryList(array('dir' => "{$base}/unittest-cont1/e/not/exists"));
$items = $this->listToArray($iter);
$this->assertEquals(array(), $items, "Directory listing is empty.");
}