本文整理汇总了PHP中OCP\Files\Folder::getDirectoryListing方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::getDirectoryListing方法的具体用法?PHP Folder::getDirectoryListing怎么用?PHP Folder::getDirectoryListing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\Files\Folder
的用法示例。
在下文中一共展示了Folder::getDirectoryListing方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNodes
/**
* Retrieves all files and sub-folders contained in a folder
*
* If we can't find anything in the current folder, we throw an exception as there is no point
* in doing any more work, but if we're looking at a sub-folder, we return an empty array so
* that it can be simply ignored
*
* @param Folder $folder
* @param int $subDepth
*
* @return array
*
* @throws NotFoundServiceException
*/
protected function getNodes($folder, $subDepth)
{
try {
$nodes = $folder->getDirectoryListing();
} catch (\Exception $exception) {
$nodes = $this->recoverFromGetNodesError($subDepth, $exception);
}
return $nodes;
}
示例2: remove
/**
* remove the users avatar
* @return void
*/
public function remove()
{
$regex = '/^avatar\\.([0-9]+\\.)?(jpg|png)$/';
$avatars = $this->folder->getDirectoryListing();
foreach ($avatars as $avatar) {
if (preg_match($regex, $avatar->getName())) {
$avatar->delete();
}
}
$this->user->triggerChange('avatar');
}
示例3: getSharesInDir
/**
* @param \OCP\Files\Folder $folder
* @return \OC_OCS_Result
*/
private function getSharesInDir($folder)
{
if (!$folder instanceof \OCP\Files\Folder) {
return new \OC_OCS_Result(null, 400, "not a directory");
}
$nodes = $folder->getDirectoryListing();
/** @var \OCP\Share\IShare[] $shares */
$shares = [];
foreach ($nodes as $node) {
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_USER, $node, false, -1, 0));
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $node, false, -1, 0));
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_LINK, $node, false, -1, 0));
if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_REMOTE, $node, false, -1, 0));
}
}
$formatted = [];
foreach ($shares as $share) {
try {
$formatted[] = $this->formatShare($share);
} catch (NotFoundException $e) {
//Ignore this share
}
}
return new \OC_OCS_Result($formatted);
}
示例4: getSharesInDir
/**
* @param \OCP\Files\Folder $folder
* @return \OC_OCS_Result
*/
private function getSharesInDir($folder)
{
if (!$folder instanceof \OCP\Files\Folder) {
return new \OC_OCS_Result(null, 400, "not a directory");
}
$nodes = $folder->getDirectoryListing();
/** @var IShare[] $shares */
$shares = [];
foreach ($nodes as $node) {
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $node, false, -1, 0));
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $node, false, -1, 0));
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_LINK, $node, false, -1, 0));
//TODO: Add federated shares
}
$formatted = [];
foreach ($shares as $share) {
$formatted[] = $this->formatShare($share);
}
return new \OC_OCS_Result($formatted);
}