本文整理匯總了PHP中OCP\Files\Folder::newFolder方法的典型用法代碼示例。如果您正苦於以下問題:PHP Folder::newFolder方法的具體用法?PHP Folder::newFolder怎麽用?PHP Folder::newFolder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OCP\Files\Folder
的用法示例。
在下文中一共展示了Folder::newFolder方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testUpdateFileTags
public function testUpdateFileTags()
{
$tag1 = 'tag1';
$tag2 = 'tag2';
$subdir = $this->root->newFolder('subdir');
$testFile = $subdir->newFile('test.txt');
$testFile->putContent('test contents');
$fileId = $testFile->getId();
// set tags
$this->tagService->updateFileTags('subdir/test.txt', array($tag1, $tag2));
$this->assertEquals(array($fileId), $this->tagger->getIdsForTag($tag1));
$this->assertEquals(array($fileId), $this->tagger->getIdsForTag($tag2));
// remove tag
$result = $this->tagService->updateFileTags('subdir/test.txt', array($tag2));
$this->assertEquals(array(), $this->tagger->getIdsForTag($tag1));
$this->assertEquals(array($fileId), $this->tagger->getIdsForTag($tag2));
// clear tags
$result = $this->tagService->updateFileTags('subdir/test.txt', array());
$this->assertEquals(array(), $this->tagger->getIdsForTag($tag1));
$this->assertEquals(array(), $this->tagger->getIdsForTag($tag2));
// non-existing file
$caught = false;
try {
$this->tagService->updateFileTags('subdir/unexist.txt', array($tag1));
} catch (\OCP\Files\NotFoundException $e) {
$caught = true;
}
$this->assertTrue($caught);
$subdir->delete();
}
示例2: copyr
/**
* copies a directory recursively by using streams
*
* @param string $source
* @param \OCP\Files\Folder $target
* @return void
*/
public static function copyr($source, \OCP\Files\Folder $target) {
$dir = opendir($source);
while (false !== ($file = readdir($dir))) {
if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
if (is_dir($source . '/' . $file)) {
$child = $target->newFolder($file);
self::copyr($source . '/' . $file, $child);
} else {
$child = $target->newFile($file);
stream_copy_to_stream(fopen($source . '/' . $file,'r'), $child->fopen('w'));
}
}
}
closedir($dir);
}
示例3: getOrCreateSubFolder
/**
* @param \OCP\Files\Folder $parent
* @param string $folderName
* @return \OCP\Files\Folder
* @throws SetUpException
*/
private function getOrCreateSubFolder(Folder $parent, $folderName)
{
if ($parent->nodeExists($folderName)) {
return $parent->get($folderName);
} else {
return $parent->newFolder($folderName);
}
}
示例4: createStructure
/**
* Creates the folder structure and adds test images
*
* This could be refined by adding tests to make sure we have access to the files
*
* @param Folder $baseFolder
* @param array <string|int,string|array> $structure
*/
private function createStructure($baseFolder, $structure)
{
foreach ($structure as $key => $value) {
if (is_array($value)) {
$subFolder = $baseFolder->newFolder($key);
if ($key === $this->sharedFolderName) {
$this->sharedFolder = $subFolder;
}
if (!empty($value)) {
$this->createStructure($subFolder, $value);
}
} else {
$file = $this->addFile($baseFolder, $value, $value);
if ($value === $this->sharedFileName) {
$this->sharedFile = $file;
}
}
}
}