本文整理汇总了PHP中OC\Files\View::getMount方法的典型用法代码示例。如果您正苦于以下问题:PHP View::getMount方法的具体用法?PHP View::getMount怎么用?PHP View::getMount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Files\View
的用法示例。
在下文中一共展示了View::getMount方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: propagateChanges
/**
* propagate the registered changes to their parent folders
*
* @param int $time (optional) the mtime to set for the folders, if not set the current time is used
*/
public function propagateChanges($time = null)
{
$changes = $this->getChanges();
$this->changedFiles = [];
if (!$time) {
$time = time();
}
foreach ($changes as $change) {
/**
* @var \OC\Files\Storage\Storage $storage
* @var string $internalPath
*/
$absolutePath = $this->view->getAbsolutePath($change);
$mount = $this->view->getMount($change);
$storage = $mount->getStorage();
$internalPath = $mount->getInternalPath($absolutePath);
if ($storage) {
$propagator = $storage->getPropagator();
$propagatedEntries = $propagator->propagateChange($internalPath, $time);
foreach ($propagatedEntries as $entry) {
$absolutePath = Filesystem::normalizePath($mount->getMountPoint() . '/' . $entry['path']);
$relativePath = $this->view->getRelativePath($absolutePath);
$this->emit('\\OC\\Files', 'propagate', [$relativePath, $entry]);
}
}
}
}
示例2: getNodeForPath
/**
* Returns the INode object for the requested path
*
* @param string $path
* @throws \Sabre\DAV\Exception\ServiceUnavailable
* @throws \Sabre\DAV\Exception\NotFound
* @return \Sabre\DAV\INode
*/
public function getNodeForPath($path)
{
if (!$this->fileView) {
throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup');
}
$path = trim($path, '/');
if (isset($this->cache[$path])) {
return $this->cache[$path];
}
// Is it the root node?
if (!strlen($path)) {
return $this->rootNode;
}
if (pathinfo($path, PATHINFO_EXTENSION) === 'part') {
// read from storage
$absPath = $this->fileView->getAbsolutePath($path);
$mount = $this->fileView->getMount($path);
$storage = $mount->getStorage();
$internalPath = $mount->getInternalPath($absPath);
if ($storage) {
/**
* @var \OC\Files\Storage\Storage $storage
*/
$scanner = $storage->getScanner($internalPath);
// get data directly
$data = $scanner->getData($internalPath);
$info = new FileInfo($absPath, $storage, $internalPath, $data, $mount);
} else {
$info = null;
}
} else {
// read from cache
try {
$info = $this->fileView->getFileInfo($path);
} catch (StorageNotAvailableException $e) {
throw new \Sabre\DAV\Exception\ServiceUnavailable('Storage not available');
} catch (StorageInvalidException $e) {
throw new \Sabre\DAV\Exception\NotFound('Storage ' . $path . ' is invalid');
}
}
if (!$info) {
throw new \Sabre\DAV\Exception\NotFound('File with name ' . $path . ' could not be located');
}
if ($info->getType() === 'dir') {
$node = new \OC_Connector_Sabre_Directory($this->fileView, $info);
} else {
$node = new \OC_Connector_Sabre_File($this->fileView, $info);
}
$this->cache[$path] = $node;
return $node;
}
示例3: renameHook
public function renameHook($params)
{
$path1 = $params['oldpath'];
$path2 = $params['newpath'];
$fullPath1 = $this->baseView->getAbsolutePath($path1);
$fullPath2 = $this->baseView->getAbsolutePath($path2);
$mount1 = $this->baseView->getMount($path1);
$mount2 = $this->baseView->getMount($path2);
if ($mount1 instanceof SharedMount and $mount1->getInternalPath($fullPath1) !== '') {
$this->propagateForOwner($mount1->getShare(), $mount1->getInternalPath($fullPath1), $mount1->getOwnerPropagator());
}
if ($mount1 !== $mount2 and $mount2 instanceof SharedMount and $mount2->getInternalPath($fullPath2) !== '') {
$this->propagateForOwner($mount2->getShare(), $mount2->getInternalPath($fullPath2), $mount2->getOwnerPropagator());
}
}
示例4: shareNotificationForOriginalOwners
/**
* Add notifications for the owners whose files have been reshared
*
* @param string $currentOwner
* @param string $subject
* @param string $shareWith
* @param int $fileSource
* @param string $itemType
*/
protected function shareNotificationForOriginalOwners($currentOwner, $subject, $shareWith, $fileSource, $itemType)
{
// Get the full path of the current user
$this->view->chroot('/' . $currentOwner . '/files');
try {
$path = $this->view->getPath($fileSource);
} catch (NotFoundException $e) {
return;
}
/**
* Get the original owner and his path
*/
$owner = $this->view->getOwner($path);
if ($owner !== $currentOwner) {
$this->reshareNotificationForSharer($owner, $subject, $shareWith, $fileSource, $itemType);
}
/**
* Get the sharee who shared the item with the currentUser
*/
$this->view->chroot('/' . $currentOwner . '/files');
$mount = $this->view->getMount($path);
if (!$mount instanceof IMountPoint) {
return;
}
$storage = $mount->getStorage();
if (!$storage->instanceOfStorage('OC\\Files\\Storage\\Shared')) {
return;
}
/** @var \OC\Files\Storage\Shared $storage */
$shareOwner = $storage->getSharedFrom();
if ($shareOwner === '' || $shareOwner === null || $shareOwner === $owner || $shareOwner === $currentOwner) {
return;
}
$this->reshareNotificationForSharer($shareOwner, $subject, $shareWith, $fileSource, $itemType);
}
示例5: reorganizeFolderStructureForUser
/**
* reorganize folder structure for user
*
* @param string $user
*/
public function reorganizeFolderStructureForUser($user)
{
// backup all keys
\OC_Util::tearDownFS();
\OC_Util::setupFS($user);
if ($this->backupUserKeys($user)) {
// rename users private key
$this->renameUsersPrivateKey($user);
$this->renameUsersPublicKey($user);
// rename file keys
$path = '/files_encryption/keys';
$this->renameFileKeys($user, $path);
$trashPath = '/files_trashbin/keys';
if (\OC_App::isEnabled('files_trashbin') && $this->view->is_dir($user . '/' . $trashPath)) {
$this->renameFileKeys($user, $trashPath, true);
$this->view->deleteAll($trashPath);
}
// delete old folders
$this->deleteOldKeys($user);
$this->view->getMount('/' . $user)->getStorage()->getScanner()->scan('files_encryption');
}
}
示例6: getNodeForPath
/**
* Returns the INode object for the requested path
*
* @param string $path
* @return \Sabre\DAV\INode
* @throws InvalidPath
* @throws \Sabre\DAV\Exception\Locked
* @throws \Sabre\DAV\Exception\NotFound
* @throws \Sabre\DAV\Exception\ServiceUnavailable
*/
public function getNodeForPath($path)
{
if (!$this->fileView) {
throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup');
}
$path = trim($path, '/');
if (isset($this->cache[$path])) {
return $this->cache[$path];
}
if ($path) {
try {
$this->fileView->verifyPath($path, basename($path));
} catch (\OCP\Files\InvalidPathException $ex) {
throw new InvalidPath($ex->getMessage());
}
}
// Is it the root node?
if (!strlen($path)) {
return $this->rootNode;
}
if (pathinfo($path, PATHINFO_EXTENSION) === 'part') {
// read from storage
$absPath = $this->fileView->getAbsolutePath($path);
$mount = $this->fileView->getMount($path);
$storage = $mount->getStorage();
$internalPath = $mount->getInternalPath($absPath);
if ($storage && $storage->file_exists($internalPath)) {
/**
* @var \OC\Files\Storage\Storage $storage
*/
// get data directly
$data = $storage->getMetaData($internalPath);
$info = new FileInfo($absPath, $storage, $internalPath, $data, $mount);
} else {
$info = null;
}
} else {
// resolve chunk file name to real name, if applicable
$path = $this->resolveChunkFile($path);
// read from cache
try {
$info = $this->fileView->getFileInfo($path);
} catch (StorageNotAvailableException $e) {
throw new \Sabre\DAV\Exception\ServiceUnavailable('Storage not available');
} catch (StorageInvalidException $e) {
throw new \Sabre\DAV\Exception\NotFound('Storage ' . $path . ' is invalid');
} catch (LockedException $e) {
throw new \Sabre\DAV\Exception\Locked();
}
}
if (!$info) {
throw new \Sabre\DAV\Exception\NotFound('File with name ' . $path . ' could not be located');
}
if ($info->getType() === 'dir') {
$node = new \OCA\DAV\Connector\Sabre\Directory($this->fileView, $info, $this);
} else {
$node = new \OCA\DAV\Connector\Sabre\File($this->fileView, $info);
}
$this->cache[$path] = $node;
return $node;
}
示例7: getStorage
/**
* get storage of path
*
* @param string $path
* @return \OC\Files\Storage\Storage
*/
public function getStorage($path)
{
$storage = $this->files->getMount($path)->getStorage();
return $storage;
}