本文整理汇总了PHP中OC\Files\Filesystem::getMountManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::getMountManager方法的具体用法?PHP Filesystem::getMountManager怎么用?PHP Filesystem::getMountManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Files\Filesystem
的用法示例。
在下文中一共展示了Filesystem::getMountManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createShare
/**
* create a new share
*
* @param array $params
* @return \OC_OCS_Result
*/
public function createShare($params)
{
if (!$this->isS2SEnabled(true)) {
return new \OC_OCS_Result(null, 503, 'Server does not support federated cloud sharing');
}
$remote = isset($_POST['remote']) ? $_POST['remote'] : null;
$token = isset($_POST['token']) ? $_POST['token'] : null;
$name = isset($_POST['name']) ? $_POST['name'] : null;
$owner = isset($_POST['owner']) ? $_POST['owner'] : null;
$shareWith = isset($_POST['shareWith']) ? $_POST['shareWith'] : null;
$remoteId = isset($_POST['remoteId']) ? (int) $_POST['remoteId'] : null;
if ($remote && $token && $name && $owner && $remoteId && $shareWith) {
if (!\OCP\Util::isValidFileName($name)) {
return new \OC_OCS_Result(null, 400, 'The mountpoint name contains invalid characters.');
}
// FIXME this should be a method in the user management instead
\OCP\Util::writeLog('files_sharing', 'shareWith before, ' . $shareWith, \OCP\Util::DEBUG);
\OCP\Util::emitHook('\\OCA\\Files_Sharing\\API\\Server2Server', 'preLoginNameUsedAsUserName', array('uid' => &$shareWith));
\OCP\Util::writeLog('files_sharing', 'shareWith after, ' . $shareWith, \OCP\Util::DEBUG);
if (!\OCP\User::userExists($shareWith)) {
return new \OC_OCS_Result(null, 400, 'User does not exists');
}
\OC_Util::setupFS($shareWith);
$externalManager = new \OCA\Files_Sharing\External\Manager(\OC::$server->getDatabaseConnection(), \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), \OC::$server->getHTTPHelper(), \OC::$server->getNotificationManager(), $shareWith);
try {
$externalManager->addShare($remote, $token, '', $name, $owner, false, $shareWith, $remoteId);
$user = $owner . '@' . $this->cleanupRemote($remote);
\OC::$server->getActivityManager()->publishActivity(Activity::FILES_SHARING_APP, Activity::SUBJECT_REMOTE_SHARE_RECEIVED, array($user, trim($name, '/')), '', array(), '', '', $shareWith, Activity::TYPE_REMOTE_SHARE, Activity::PRIORITY_LOW);
/**
* FIXME
$urlGenerator = \OC::$server->getURLGenerator();
$notificationManager = \OC::$server->getNotificationManager();
$notification = $notificationManager->createNotification();
$notification->setApp('files_sharing')
->setUser($shareWith)
->setTimestamp(time())
->setObject('remote_share', $remoteId)
->setSubject('remote_share', [$user, trim($name, '/')]);
$declineAction = $notification->createAction();
$declineAction->setLabel('decline')
->setLink($urlGenerator->getAbsoluteURL('/ocs/v1.php/apps/files_sharing/api/v1/remote_shares/' . $remoteId), 'DELETE');
$notification->addAction($declineAction);
$acceptAction = $notification->createAction();
$acceptAction->setLabel('accept')
->setLink($urlGenerator->getAbsoluteURL('/ocs/v1.php/apps/files_sharing/api/v1/remote_shares/' . $remoteId), 'POST');
$notification->addAction($acceptAction);
$notificationManager->notify($notification);
*/
return new \OC_OCS_Result();
} catch (\Exception $e) {
\OCP\Util::writeLog('files_sharing', 'server can not add remote share, ' . $e->getMessage(), \OCP\Util::ERROR);
return new \OC_OCS_Result(null, 500, 'internal server error, was not able to add share from ' . $remote);
}
}
return new \OC_OCS_Result(null, 400, 'server can not add remote share, missing parameter');
}
示例2: __construct
public function __construct(array $urlParams = array())
{
parent::__construct('files_sharing', $urlParams);
$container = $this->getContainer();
$server = $container->getServer();
/**
* Controllers
*/
$container->registerService('ShareController', function (SimpleContainer $c) use($server) {
return new ShareController($c->query('AppName'), $c->query('Request'), $c->query('UserSession'), $server->getAppConfig(), $server->getConfig(), $c->query('URLGenerator'), $c->query('UserManager'), $server->getLogger(), $server->getActivityManager());
});
$container->registerService('ExternalSharesController', function (SimpleContainer $c) {
return new ExternalSharesController($c->query('AppName'), $c->query('Request'), $c->query('IsIncomingShareEnabled'), $c->query('ExternalManager'), $c->query('HttpClientService'));
});
/**
* Core class wrappers
*/
$container->registerService('UserSession', function (SimpleContainer $c) use($server) {
return $server->getUserSession();
});
$container->registerService('URLGenerator', function (SimpleContainer $c) use($server) {
return $server->getUrlGenerator();
});
$container->registerService('UserManager', function (SimpleContainer $c) use($server) {
return $server->getUserManager();
});
$container->registerService('HttpClientService', function (SimpleContainer $c) use($server) {
return $server->getHTTPClientService();
});
$container->registerService('IsIncomingShareEnabled', function (SimpleContainer $c) {
return Helper::isIncomingServer2serverShareEnabled();
});
$container->registerService('ExternalManager', function (SimpleContainer $c) use($server) {
$user = $server->getUserSession()->getUser();
$uid = $user ? $user->getUID() : null;
return new \OCA\Files_Sharing\External\Manager($server->getDatabaseConnection(), \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), $server->getHTTPHelper(), $server->getNotificationManager(), $uid);
});
/**
* Middleware
*/
$container->registerService('SharingCheckMiddleware', function (SimpleContainer $c) use($server) {
return new SharingCheckMiddleware($c->query('AppName'), $server->getConfig(), $server->getAppManager());
});
// Execute middlewares
$container->registerMiddleware('SharingCheckMiddleware');
$container->registerService('MountProvider', function (IContainer $c) {
/** @var \OCP\IServerContainer $server */
$server = $c->query('ServerContainer');
return new MountProvider($server->getConfig(), $c->query('PropagationManager'));
});
$container->registerService('PropagationManager', function (IContainer $c) {
/** @var \OCP\IServerContainer $server */
$server = $c->query('ServerContainer');
return new PropagationManager($server->getUserSession(), $server->getConfig());
});
/*
* Register capabilities
*/
$container->registerCapability('OCA\\Files_Sharing\\Capabilities');
}
示例3: createShare
/**
* create a new share
*
* @param array $params
* @return \OC_OCS_Result
*/
public function createShare($params)
{
if (!$this->isS2SEnabled(true)) {
return new \OC_OCS_Result(null, 503, 'Server does not support federated cloud sharing');
}
$remote = isset($_POST['remote']) ? $_POST['remote'] : null;
$token = isset($_POST['token']) ? $_POST['token'] : null;
$name = isset($_POST['name']) ? $_POST['name'] : null;
$owner = isset($_POST['owner']) ? $_POST['owner'] : null;
$shareWith = isset($_POST['shareWith']) ? $_POST['shareWith'] : null;
$remoteId = isset($_POST['remoteId']) ? (int) $_POST['remoteId'] : null;
if ($remote && $token && $name && $owner && $remoteId && $shareWith) {
if (!\OCP\Util::isValidFileName($name)) {
return new \OC_OCS_Result(null, 400, 'The mountpoint name contains invalid characters.');
}
if (!\OCP\User::userExists($shareWith)) {
return new \OC_OCS_Result(null, 400, 'User does not exists');
}
\OC_Util::setupFS($shareWith);
$externalManager = new \OCA\Files_Sharing\External\Manager(\OC::$server->getDatabaseConnection(), \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), \OC::$server->getHTTPHelper(), $shareWith);
try {
$externalManager->addShare($remote, $token, '', $name, $owner, false, $shareWith, $remoteId);
$user = $owner . '@' . $this->cleanupRemote($remote);
\OC::$server->getActivityManager()->publishActivity('files_sharing', \OCA\Files_Sharing\Activity::SUBJECT_REMOTE_SHARE_RECEIVED, array($user), '', array(), '', '', $shareWith, \OCA\Files_Sharing\Activity::TYPE_REMOTE_SHARE, \OCA\Files_Sharing\Activity::PRIORITY_LOW);
return new \OC_OCS_Result();
} catch (\Exception $e) {
\OCP\Util::writeLog('files_sharing', 'server can not add remote share, ' . $e->getMessage(), \OCP\Util::ERROR);
return new \OC_OCS_Result(null, 500, 'internal server error, was not able to add share from ' . $remote);
}
}
return new \OC_OCS_Result(null, 400, 'server can not add remote share, missing parameter');
}
示例4: determineIcon
public static function determineIcon($file)
{
if ($file['type'] === 'dir') {
$dir = $file['directory'];
$absPath = \OC\Files\Filesystem::getView()->getAbsolutePath($dir . '/' . $file['name']);
$mount = \OC\Files\Filesystem::getMountManager()->find($absPath);
if (!is_null($mount)) {
$sid = $mount->getStorageId();
if (!is_null($sid)) {
$sid = explode(':', $sid);
if ($sid[0] === 'shared') {
return \OC_Helper::mimetypeIcon('dir-shared');
}
if ($sid[0] !== 'local' and $sid[0] !== 'home') {
return \OC_Helper::mimetypeIcon('dir-external');
}
}
}
return \OC_Helper::mimetypeIcon('dir');
}
if ($file['isPreviewAvailable']) {
$pathForPreview = $file['directory'] . '/' . $file['name'];
return \OC_Helper::previewIcon($pathForPreview) . '&c=' . $file['etag'];
}
return \OC_Helper::mimetypeIcon($file['mimetype']);
}
示例5: declineShare
/**
* Decline a remote share
*
* @param array $params contains the shareID 'id' which should be declined
* @return \OC_OCS_Result
*/
public static function declineShare($params)
{
$externalManager = new Manager(\OC::$server->getDatabaseConnection(), Filesystem::getMountManager(), Filesystem::getLoader(), \OC::$server->getHTTPHelper(), \OC_User::getUser());
if ($externalManager->declineShare($params['id'])) {
return new \OC_OCS_Result();
}
return new \OC_OCS_Result(null, 404, "wrong share ID, share doesn't exist.");
}
示例6: setUp
public function setUp()
{
parent::setUp();
$this->userId = $this->getUniqueID();
$this->createUser($this->userId, 'pass');
$this->registerMount($this->userId, new Temporary(), '/' . $this->userId . '/files/');
\OC_Util::setupFS($this->userId);
$this->view = new View();
$this->root = new Root(Filesystem::getMountManager(), $this->view, \OC::$server->getUserManager()->get($this->userId));
}
示例7: getUpdate
/**
* @return Update
*/
private static function getUpdate()
{
if (is_null(self::$updater)) {
$user = \OC::$server->getUserSession()->getUser();
$uid = '';
if ($user) {
$uid = $user->getUID();
}
self::$updater = new Update(new View(), new Util(new View(), \OC::$server->getUserManager(), \OC::$server->getGroupManager(), \OC::$server->getConfig()), Filesystem::getMountManager(), \OC::$server->getEncryptionManager(), \OC::$server->getEncryptionFilesHelper(), $uid);
}
return self::$updater;
}
示例8: getMounts
/**
* get all storages for $dir
*
* @param string $dir
* @return \OC\Files\Mount\MountPoint[]
*/
protected function getMounts($dir)
{
//TODO: move to the node based fileapi once that's done
\OC_Util::tearDownFS();
\OC_Util::setupFS($this->user);
$mountManager = Filesystem::getMountManager();
$mounts = $mountManager->findIn($dir);
$mounts[] = $mountManager->find($dir);
$mounts = array_reverse($mounts);
//start with the mount of $dir
return $mounts;
}
示例9: __construct
public function __construct(array $urlParams = array())
{
parent::__construct('files_sharing', $urlParams);
$container = $this->getContainer();
$server = $container->getServer();
/**
* Controllers
*/
$container->registerService('ShareController', function (SimpleContainer $c) use($server) {
$federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application('federatedfilesharing');
return new ShareController($c->query('AppName'), $c->query('Request'), $server->getConfig(), $server->getURLGenerator(), $server->getUserManager(), $server->getLogger(), $server->getActivityManager(), $server->getShareManager(), $server->getSession(), $server->getPreviewManager(), $server->getRootFolder(), $federatedSharingApp->getFederatedShareProvider());
});
$container->registerService('ExternalSharesController', function (SimpleContainer $c) {
return new ExternalSharesController($c->query('AppName'), $c->query('Request'), $c->query('ExternalManager'), $c->query('HttpClientService'));
});
/**
* Core class wrappers
*/
$container->registerService('HttpClientService', function (SimpleContainer $c) use($server) {
return $server->getHTTPClientService();
});
$container->registerService('ExternalManager', function (SimpleContainer $c) use($server) {
$user = $server->getUserSession()->getUser();
$uid = $user ? $user->getUID() : null;
$discoveryManager = new DiscoveryManager(\OC::$server->getMemCacheFactory(), \OC::$server->getHTTPClientService());
return new \OCA\Files_Sharing\External\Manager($server->getDatabaseConnection(), \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), $server->getHTTPHelper(), $server->getNotificationManager(), $discoveryManager, $uid);
});
/**
* Middleware
*/
$container->registerService('SharingCheckMiddleware', function (SimpleContainer $c) use($server) {
return new SharingCheckMiddleware($c->query('AppName'), $server->getConfig(), $server->getAppManager(), $c['ControllerMethodReflector']);
});
// Execute middlewares
$container->registerMiddleware('SharingCheckMiddleware');
$container->registerService('MountProvider', function (IContainer $c) {
/** @var \OCP\IServerContainer $server */
$server = $c->query('ServerContainer');
return new MountProvider($server->getConfig(), $server->getShareManager(), $server->getLogger());
});
$container->registerService('ExternalMountProvider', function (IContainer $c) {
/** @var \OCP\IServerContainer $server */
$server = $c->query('ServerContainer');
return new \OCA\Files_Sharing\External\MountProvider($server->getDatabaseConnection(), function () use($c) {
return $c->query('ExternalManager');
});
});
/*
* Register capabilities
*/
$container->registerCapability('OCA\\Files_Sharing\\Capabilities');
}
示例10: unshareChildren
/**
* unshare shared items below the deleted folder
*
* @param string $path
*/
private function unshareChildren($path)
{
$view = new \OC\Files\View('/');
// find share mount points within $path and unmount them
$mountManager = \OC\Files\Filesystem::getMountManager();
$mountedShares = $mountManager->findIn($path);
foreach ($mountedShares as $mount) {
if ($mount->getStorage()->instanceOfStorage('OCA\\Files_Sharing\\ISharedStorage')) {
$mountPoint = $mount->getMountPoint();
$view->unlink($mountPoint);
}
}
}
示例11: renameChildren
/**
* rename mount point from the children if the parent was renamed
*
* @param string $oldPath old path relative to data/user/files
* @param string $newPath new path relative to data/user/files
*/
private static function renameChildren($oldPath, $newPath)
{
$absNewPath = \OC\Files\Filesystem::normalizePath('/' . \OCP\User::getUser() . '/files/' . $newPath);
$absOldPath = \OC\Files\Filesystem::normalizePath('/' . \OCP\User::getUser() . '/files/' . $oldPath);
$mountManager = \OC\Files\Filesystem::getMountManager();
$mountedShares = $mountManager->findIn('/' . \OCP\User::getUser() . '/files/' . $oldPath);
foreach ($mountedShares as $mount) {
if ($mount->getStorage()->instanceOfStorage('OCA\\Files_Sharing\\ISharedStorage')) {
$mountPoint = $mount->getMountPoint();
$target = str_replace($absOldPath, $absNewPath, $mountPoint);
$mount->moveMount($target);
}
}
}
示例12: setUp
protected function setUp()
{
parent::setUp();
$manager = \OC\Files\Filesystem::getMountManager();
\OC_Hook::clear('OC_Filesystem');
$user = new User($this->getUniqueID('user'), new \Test\Util\User\Dummy());
$this->loginAsUser($user->getUID());
$this->view = new View();
$this->root = new Root($manager, $this->view, $user);
$storage = new Temporary(array());
$subStorage = new Temporary(array());
$this->storages[] = $storage;
$this->storages[] = $subStorage;
$this->root->mount($storage, '/');
$this->root->mount($subStorage, '/substorage/');
}
示例13: wrapStorage
/**
* Wraps the given storage when it is not a shared storage
*
* @param string $mountPoint
* @param Storage $storage
* @param IMountPoint $mount
* @return Encryption|Storage
*/
public function wrapStorage($mountPoint, Storage $storage, IMountPoint $mount)
{
$parameters = ['storage' => $storage, 'mountPoint' => $mountPoint, 'mount' => $mount];
if (!$storage->instanceOfStorage('OC\\Files\\Storage\\Shared') && !$storage->instanceOfStorage('OCA\\Files_Sharing\\External\\Storage') && !$storage->instanceOfStorage('OC\\Files\\Storage\\OwnCloud')) {
$user = \OC::$server->getUserSession()->getUser();
$mountManager = Filesystem::getMountManager();
$uid = $user ? $user->getUID() : null;
$fileHelper = \OC::$server->getEncryptionFilesHelper();
$keyStorage = \OC::$server->getEncryptionKeyStorage();
$util = new Util(new View(), \OC::$server->getUserManager(), \OC::$server->getGroupManager(), \OC::$server->getConfig());
$update = new Update(new View(), $util, Filesystem::getMountManager(), $this->manager, $fileHelper, $uid);
return new Encryption($parameters, $this->manager, $util, $this->logger, $fileHelper, $uid, $keyStorage, $update, $mountManager, $this->arrayCache);
} else {
return $storage;
}
}
示例14: testReuseExistingFile
public function testReuseExistingFile()
{
$storage = new Temporary(array());
$mount = new MountPoint($storage, '');
Filesystem::getMountManager()->addMount($mount);
$cache = $storage->getCache();
$storage->mkdir('folder');
$storage->file_put_contents('foo.txt', 'qwerty');
$storage->file_put_contents('folder/bar.txt', 'qwerty');
$scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), \OC::$server->getLogger());
$scanner->addMount($mount);
$scanner->scan('');
$this->assertTrue($cache->inCache('folder/bar.txt'));
$old = $cache->get('folder/bar.txt');
$scanner->scan('');
$new = $cache->get('folder/bar.txt');
$this->assertEquals($old, $new);
}
示例15: testHomeStorageWrapperWithQuota
/**
* Tests that the home storage is not wrapped when no quota exists.
*/
function testHomeStorageWrapperWithQuota()
{
$user1 = $this->getUniqueID();
\OC_User::createUser($user1, 'test');
\OC::$server->getConfig()->setUserValue($user1, 'files', 'quota', '1024');
\OC_User::setUserId($user1);
\OC_Util::setupFS($user1);
$userMount = \OC\Files\Filesystem::getMountManager()->find('/' . $user1 . '/');
$this->assertNotNull($userMount);
$this->assertTrue($userMount->getStorage()->instanceOfStorage('\\OC\\Files\\Storage\\Wrapper\\Quota'));
// ensure that root wasn't wrapped
$rootMount = \OC\Files\Filesystem::getMountManager()->find('/');
$this->assertNotNull($rootMount);
$this->assertNotInstanceOf('\\OC\\Files\\Storage\\Wrapper\\Quota', $rootMount->getStorage());
// clean up
\OC_User::setUserId('');
\OC_User::deleteUser($user1);
\OC::$server->getConfig()->deleteAllUserValues($user1);
\OC_Util::tearDownFS();
}