本文整理汇总了PHP中OCP\Files\Folder::getById方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::getById方法的具体用法?PHP Folder::getById怎么用?PHP Folder::getById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\Files\Folder
的用法示例。
在下文中一共展示了Folder::getById方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createShare
/**
* Create a share object from an database row
*
* @param mixed[] $data
* @return Share
*/
private function createShare($data)
{
$share = new Share();
$share->setId((int) $data['id'])->setShareType((int) $data['share_type'])->setPermissions((int) $data['permissions'])->setTarget($data['file_target'])->setShareTime((int) $data['stime'])->setMailSend((bool) $data['mail_send']);
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
$share->setSharedWith($this->userManager->get($data['share_with']));
} else {
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
$share->setSharedWith($this->groupManager->get($data['share_with']));
} else {
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
$share->setPassword($data['share_with']);
$share->setToken($data['token']);
} else {
$share->setSharedWith($data['share_with']);
}
}
}
$share->setSharedBy($this->userManager->get($data['uid_owner']));
// TODO: getById can return an array. How to handle this properly??
$path = $this->userFolder->getById((int) $data['file_source']);
$path = $path[0];
$share->setPath($path);
$owner = $path->getStorage()->getOwner('.');
if ($owner !== false) {
$share->setShareOwner($this->userManager->get($owner));
}
if ($data['expiration'] !== null) {
$expiration = \DateTime::createFromFormat('Y-m-d H:i:s', $data['expiration']);
$share->setExpirationDate($expiration);
}
return $share;
}
示例2: getResourceFromId
/**
* Returns the resource identified by the given ID
*
* @param int $resourceId
*
* @return Node
*
* @throws NotFoundEnvException
*/
public function getResourceFromId($resourceId)
{
$resourcesArray = $this->userFolder->getById($resourceId);
if ($resourcesArray[0] === null) {
throw new NotFoundEnvException('Could not locate file linked to ID: ' . $resourceId);
}
return $resourcesArray[0];
}
示例3: getFilesByTag
/**
* Get all files for the given tag
*
* @param array $tagName tag name to filter by
* @return FileInfo[] list of matching files
* @throws \Exception if the tag does not exist
*/
public function getFilesByTag($tagName)
{
try {
$fileIds = $this->tagger->getIdsForTag($tagName);
} catch (\Exception $e) {
return [];
}
$fileInfos = [];
foreach ($fileIds as $fileId) {
$nodes = $this->homeFolder->getById((int) $fileId);
foreach ($nodes as $node) {
/** @var \OC\Files\Node\Node $node */
$fileInfos[] = $node->getFileInfo();
}
}
return $fileInfos;
}
示例4: getFilesByTag
/**
* Get all files for the given tag
*
* @param string $tagName tag name to filter by
* @return Node[] list of matching files
* @throws \Exception if the tag does not exist
*/
public function getFilesByTag($tagName)
{
try {
$fileIds = $this->tagger->getIdsForTag($tagName);
} catch (\Exception $e) {
return [];
}
$allNodes = [];
foreach ($fileIds as $fileId) {
$allNodes = array_merge($allNodes, $this->homeFolder->getById((int) $fileId));
}
return $allNodes;
}
示例5: cover
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function cover()
{
// we no longer need the session to be kept open
session_write_close();
$albumId = $this->getIdFromSlug($this->params('albumIdOrSlug'));
$album = $this->albumBusinessLayer->find($albumId, $this->userId);
$nodes = $this->userFolder->getById($album->getCoverFileId());
if (count($nodes) > 0) {
// get the first valid node
$node = $nodes[0];
$mime = $node->getMimeType();
$content = $node->getContent();
return new FileResponse(array('mimetype' => $mime, 'content' => $content));
}
$r = new Response();
$r->setStatus(Http::STATUS_NOT_FOUND);
return $r;
}
示例6: getFilePath
/**
* {@inheritDoc}
*/
public function getFilePath($itemSource, $uidOwner)
{
try {
$calendar = $this->calendars->find($itemSource, $uidOwner);
$fileId = $calendar->getFileId();
if ($fileId === null) {
return false;
}
$files = $this->userFolder->getById($fileId);
if (!$files || empty($files)) {
return false;
} else {
return $files[0]->getPath();
}
} catch (BusinessLayer\Exception $ex) {
return false;
}
}
示例7: getFilePath
/**
* {@inheritDoc}
*/
public function getFilePath($itemSource, $uidOwner)
{
try {
if (substr_count($itemSource, '::') === 0) {
return false;
}
list($calendarId) = explode('::', $itemSource, 1);
$calendar = $this->calendars->find($calendarId, $uidOwner);
$fileId = $calendar->getFileId();
if ($fileId === null) {
return false;
}
$files = $this->userFolder->getById($fileId);
if (!$files || empty($files)) {
return false;
} else {
return $files[0]->getPath();
}
} catch (BusinessLayer\Exception $ex) {
return false;
}
}
示例8: childExists
/**
* Checks if a child-node with the specified name exists
*
* @param string $name
* @return bool
*/
function childExists($name)
{
$nodes = $this->fileRoot->getById(intval($name));
return !empty($nodes);
}
示例9: getFileById
/**
* @param Folder $folder
* @param int $id
* @throws NoteDoesNotExistException
* @return \OCP\Files\File
*/
private function getFileById($folder, $id)
{
$file = $folder->getById($id);
if (count($file) <= 0 || !$this->isNote($file[0])) {
throw new NoteDoesNotExistException();
}
return $file[0];
}
示例10: getFileById
/**
* @param Folder $folder
* @param int $id
* @throws NoteDoesNotExistException
* @return \OCP\Files\File
*/
private function getFileById($folder, $id)
{
$file = $folder->getById($id);
if (count($file) <= 0 || $file[0]->getMimeType() !== 'text/plain') {
throw new NoteDoesNotExistException();
}
return $file[0];
}
示例11: getResourceFromFolderAndId
/**
* Returns the resource found in a specific folder and identified by the given ID
*
* @param Folder $folder
* @param int $resourceId
*
* @return Node
* @throws NotFoundEnvException
*/
private function getResourceFromFolderAndId($folder, $resourceId)
{
$resourcesArray = $folder->getById($resourceId);
if ($resourcesArray[0] === null) {
throw new NotFoundEnvException('Could not locate node linked to ID: ' . $resourceId);
}
return $resourcesArray[0];
}