本文整理汇总了PHP中OC\Files\Filesystem::addStorageWrapper方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::addStorageWrapper方法的具体用法?PHP Filesystem::addStorageWrapper怎么用?PHP Filesystem::addStorageWrapper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Files\Filesystem
的用法示例。
在下文中一共展示了Filesystem::addStorageWrapper方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setupFS
/**
* @brief Can be set up
* @param string $user
* @return boolean
* @description configure the initial filesystem based on the configuration
*/
public static function setupFS($user = '')
{
//setting up the filesystem twice can only lead to trouble
if (self::$fsSetup) {
return false;
}
// If we are not forced to load a specific user we load the one that is logged in
if ($user == "" && OC_User::isLoggedIn()) {
$user = OC_User::getUser();
}
// load all filesystem apps before, so no setup-hook gets lost
if (!isset($RUNTIME_NOAPPS) || !$RUNTIME_NOAPPS) {
OC_App::loadApps(array('filesystem'));
}
// the filesystem will finish when $user is not empty,
// mark fs setup here to avoid doing the setup from loading
// OC_Filesystem
if ($user != '') {
self::$fsSetup = true;
}
$configDataDirectory = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
//first set up the local "root" storage
\OC\Files\Filesystem::initMounts();
if (!self::$rootMounted) {
\OC\Files\Filesystem::mount('\\OC\\Files\\Storage\\Local', array('datadir' => $configDataDirectory), '/');
self::$rootMounted = true;
}
//if we aren't logged in, there is no use to set up the filesystem
if ($user != "") {
\OC\Files\Filesystem::addStorageWrapper(function ($mountPoint, $storage) {
// set up quota for home storages, even for other users
// which can happen when using sharing
if ($storage instanceof \OC\Files\Storage\Home) {
$user = $storage->getUser()->getUID();
$quota = OC_Util::getUserQuota($user);
if ($quota !== \OC\Files\SPACE_UNLIMITED) {
return new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => $quota));
}
}
return $storage;
});
$userDir = '/' . $user . '/files';
$userRoot = OC_User::getHome($user);
$userDirectory = $userRoot . '/files';
if (!is_dir($userDirectory)) {
mkdir($userDirectory, 0755, true);
OC_Util::copySkeleton($userDirectory);
}
//jail the user into his "home" directory
\OC\Files\Filesystem::init($user, $userDir);
$fileOperationProxy = new OC_FileProxy_FileOperations();
OC_FileProxy::register($fileOperationProxy);
OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $userDir));
}
return true;
}
示例2: setupWrapper
/**
* Add wrapper for local storages
*/
public function setupWrapper()
{
\OC\Files\Filesystem::addStorageWrapper('oc_avir', function ($mountPoint, $storage) {
/**
* @var \OC\Files\Storage\Storage $storage
*/
if ($storage instanceof \OC\Files\Storage\Storage) {
$scannerFactory = $this->getContainer()->query('ScannerFactory');
$l10n = $this->getContainer()->query('L10N');
$logger = $this->getContainer()->query('Logger');
return new AvirWrapper(['storage' => $storage, 'scannerFactory' => $scannerFactory, 'l10n' => $l10n, 'logger' => $logger]);
} else {
return $storage;
}
}, 1);
}
示例3: function
$password = null;
if (isset($_POST['password'])) {
$password = $_POST['password'];
}
$relativePath = null;
if (isset($_GET['dir'])) {
$relativePath = $_GET['dir'];
}
$data = \OCA\Files_Sharing\Helper::setupFromToken($token, $relativePath, $password);
$linkItem = $data['linkItem'];
// Load the files
$path = $data['realPath'];
$isWritable = $linkItem['permissions'] & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE);
if (!$isWritable) {
\OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) {
return new \OCA\Files_Sharing\ReadOnlyWrapper(array('storage' => $storage));
});
}
$rootInfo = \OC\Files\Filesystem::getFileInfo($path);
$rootView = new \OC\Files\View('');
/**
* @param \OCP\Files\FileInfo $dir
* @param \OC\Files\View $view
* @return array
*/
function getChildInfo($dir, $view)
{
$children = $view->getDirectoryContent($dir->getPath());
$result = array();
foreach ($children as $child) {
$formated = \OCA\Files\Helper::formatFileInfo($child);
示例4: setupFS
/**
* Can be set up
*
* @param string $user
* @return boolean
* @description configure the initial filesystem based on the configuration
*/
public static function setupFS($user = '')
{
//setting up the filesystem twice can only lead to trouble
if (self::$fsSetup) {
return false;
}
// If we are not forced to load a specific user we load the one that is logged in
if ($user == "" && OC_User::isLoggedIn()) {
$user = OC_User::getUser();
}
// load all filesystem apps before, so no setup-hook gets lost
OC_App::loadApps(array('filesystem'));
// the filesystem will finish when $user is not empty,
// mark fs setup here to avoid doing the setup from loading
// OC_Filesystem
if ($user != '') {
self::$fsSetup = true;
}
//check if we are using an object storage
$objectStore = OC_Config::getValue('objectstore');
if (isset($objectStore)) {
self::initObjectStoreRootFS($objectStore);
} else {
self::initLocalStorageRootFS();
}
if ($user != '' && !OCP\User::userExists($user)) {
return false;
}
//if we aren't logged in, there is no use to set up the filesystem
if ($user != "") {
\OC\Files\Filesystem::addStorageWrapper('oc_quota', function ($mountPoint, $storage) {
// set up quota for home storages, even for other users
// which can happen when using sharing
/**
* @var \OC\Files\Storage\Storage $storage
*/
if ($storage->instanceOfStorage('\\OC\\Files\\Storage\\Home') || $storage->instanceOfStorage('\\OC\\Files\\ObjectStore\\HomeObjectStoreStorage')) {
if (is_object($storage->getUser())) {
$user = $storage->getUser()->getUID();
$quota = OC_Util::getUserQuota($user);
if ($quota !== \OCP\Files\FileInfo::SPACE_UNLIMITED) {
return new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => $quota, 'root' => 'files'));
}
}
}
return $storage;
});
// copy skeleton for local storage only
if (!isset($objectStore)) {
$userRoot = OC_User::getHome($user);
$userDirectory = $userRoot . '/files';
if (!is_dir($userDirectory)) {
mkdir($userDirectory, 0755, true);
OC_Util::copySkeleton($userDirectory);
}
}
$userDir = '/' . $user . '/files';
//jail the user into his "home" directory
\OC\Files\Filesystem::init($user, $userDir);
$fileOperationProxy = new OC_FileProxy_FileOperations();
OC_FileProxy::register($fileOperationProxy);
OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $userDir));
}
return true;
}
示例5: setupStorage
public static function setupStorage()
{
\OC\Files\Filesystem::addStorageWrapper('oc_encryption', function ($mountPoint, $storage, IMountPoint $mount) {
$parameters = ['storage' => $storage, 'mountPoint' => $mountPoint, 'mount' => $mount];
if (!$storage instanceof \OC\Files\Storage\Shared) {
$manager = \OC::$server->getEncryptionManager();
$util = new \OC\Encryption\Util(new \OC\Files\View(), \OC::$server->getUserManager(), \OC::$server->getConfig());
$user = \OC::$server->getUserSession()->getUser();
$logger = \OC::$server->getLogger();
$uid = $user ? $user->getUID() : null;
$fileHelper = \OC::$server->getEncryptionFilesHelper();
return new Encryption($parameters, $manager, $util, $logger, $fileHelper, $uid);
} else {
return $storage;
}
}, 2);
}
示例6: setupFS
/**
* Can be set up
*
* @param string $user
* @return boolean
* @description configure the initial filesystem based on the configuration
*/
public static function setupFS($user = '')
{
//setting up the filesystem twice can only lead to trouble
if (self::$fsSetup) {
return false;
}
\OC::$server->getEventLogger()->start('setup_fs', 'Setup filesystem');
// If we are not forced to load a specific user we load the one that is logged in
if ($user == "" && OC_User::isLoggedIn()) {
$user = OC_User::getUser();
}
// load all filesystem apps before, so no setup-hook gets lost
OC_App::loadApps(array('filesystem'));
// the filesystem will finish when $user is not empty,
// mark fs setup here to avoid doing the setup from loading
// OC_Filesystem
if ($user != '') {
self::$fsSetup = true;
}
\OC\Files\Filesystem::initMountManager();
\OC\Files\Filesystem::addStorageWrapper('mount_options', function ($mountPoint, \OCP\Files\Storage $storage, \OCP\Files\Mount\IMountPoint $mount) {
if ($storage->instanceOfStorage('\\OC\\Files\\Storage\\Common')) {
/** @var \OC\Files\Storage\Common $storage */
$storage->setMountOptions($mount->getOptions());
}
return $storage;
});
// install storage availability wrapper, before most other wrappers
\OC\Files\Filesystem::addStorageWrapper('oc_availability', function ($mountPoint, $storage) {
if (!$storage->isLocal()) {
return new \OC\Files\Storage\Wrapper\Availability(['storage' => $storage]);
}
return $storage;
});
\OC\Files\Filesystem::addStorageWrapper('oc_quota', function ($mountPoint, $storage) {
// set up quota for home storages, even for other users
// which can happen when using sharing
/**
* @var \OC\Files\Storage\Storage $storage
*/
if ($storage->instanceOfStorage('\\OC\\Files\\Storage\\Home') || $storage->instanceOfStorage('\\OC\\Files\\ObjectStore\\HomeObjectStoreStorage')) {
/** @var \OC\Files\Storage\Home $storage */
if (is_object($storage->getUser())) {
$user = $storage->getUser()->getUID();
$quota = OC_Util::getUserQuota($user);
if ($quota !== \OCP\Files\FileInfo::SPACE_UNLIMITED) {
return new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => $quota, 'root' => 'files'));
}
}
}
return $storage;
});
OC_Hook::emit('OC_Filesystem', 'preSetup', array('user' => $user));
//check if we are using an object storage
$objectStore = OC_Config::getValue('objectstore');
if (isset($objectStore)) {
self::initObjectStoreRootFS($objectStore);
} else {
self::initLocalStorageRootFS();
}
if ($user != '' && !OCP\User::userExists($user)) {
\OC::$server->getEventLogger()->end('setup_fs');
return false;
}
//if we aren't logged in, there is no use to set up the filesystem
if ($user != "") {
$userDir = '/' . $user . '/files';
//jail the user into his "home" directory
\OC\Files\Filesystem::init($user, $userDir);
OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $userDir));
}
\OC::$server->getEventLogger()->end('setup_fs');
return true;
}
示例7: setupWrapper
/**
* Setup the storate wrapper callback
*/
public static function setupWrapper()
{
// Set up flock
\OC\Files\Filesystem::addStorageWrapper('oc_flock', function ($mountPoint, $storage) {
/**
* @var \OC\Files\Storage\Storage $storage
*/
if ($storage instanceof \OC\Files\Storage\Storage && $storage->isLocal()) {
return new \OCA\Files_Locking\LockingWrapper(array('storage' => $storage));
} else {
return $storage;
}
});
}
示例8: setupStorage
/**
* Setup the storate wrapper callback
*/
public static function setupStorage()
{
\OC\Files\Filesystem::addStorageWrapper('oc_trashbin', function ($mountPoint, $storage) {
return new \OCA\Files_Trashbin\Storage(array('storage' => $storage, 'mountPoint' => $mountPoint), \OC::$server->getUserManager());
}, 1);
}
示例9: function
// load needed apps
$RUNTIME_APPTYPES = ['filesystem', 'authentication', 'logging'];
OC_App::loadApps($RUNTIME_APPTYPES);
OC_Util::obEnd();
// Backends
$authBackend = new OCA\DAV\Connector\PublicAuth(\OC::$server->getConfig());
$serverFactory = new OCA\DAV\Connector\Sabre\ServerFactory(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), \OC::$server->getUserSession(), \OC::$server->getMountManager(), \OC::$server->getTagManager(), \OC::$server->getEventDispatcher());
$requestUri = \OC::$server->getRequest()->getRequestUri();
$server = $serverFactory->createServer($baseuri, $requestUri, $authBackend, function () use($authBackend) {
$isAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest';
if (OCA\Files_Sharing\Helper::isOutgoingServer2serverShareEnabled() === false && !$isAjax) {
// this is what is thrown when trying to access a non-existing share
throw new \Sabre\DAV\Exception\NotAuthenticated();
}
$share = $authBackend->getShare();
$rootShare = \OCP\Share::resolveReShare($share);
$owner = $rootShare['uid_owner'];
$isWritable = $share['permissions'] & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE);
$fileId = $share['file_source'];
if (!$isWritable) {
\OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) {
return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_SHARE));
});
}
OC_Util::setupFS($owner);
$ownerView = \OC\Files\Filesystem::getView();
$path = $ownerView->getPath($fileId);
return new \OC\Files\View($ownerView->getAbsolutePath($path));
});
// And off we go!
$server->exec();
示例10: setupStorage
/**
* Add storage wrapper
*/
public function setupStorage()
{
$encryptionWrapper = new EncryptionWrapper($this->arrayCache, $this, $this->logger);
Filesystem::addStorageWrapper('oc_encryption', array($encryptionWrapper, 'wrapStorage'), 2);
}
示例11: setupStorage
/**
* Add storage wrapper
*/
public static function setupStorage()
{
$util = new Util(new View(), \OC::$server->getUserManager(), \OC::$server->getGroupManager(), \OC::$server->getConfig());
\OC\Files\Filesystem::addStorageWrapper('oc_encryption', array($util, 'wrapStorage'), 2);
}
示例12: function
OC_Util::obEnd();
\OC::$server->getSession()->close();
// Backends
$authBackend = new OCA\DAV\Connector\PublicAuth(\OC::$server->getRequest(), \OC::$server->getShareManager(), \OC::$server->getSession());
$serverFactory = new OCA\DAV\Connector\Sabre\ServerFactory(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), \OC::$server->getUserSession(), \OC::$server->getMountManager(), \OC::$server->getTagManager(), \OC::$server->getRequest());
$requestUri = \OC::$server->getRequest()->getRequestUri();
$linkCheckPlugin = new \OCA\DAV\Files\Sharing\PublicLinkCheckPlugin();
$server = $serverFactory->createServer($baseuri, $requestUri, $authBackend, function (\Sabre\DAV\Server $server) use($authBackend, $linkCheckPlugin) {
$isAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest';
$federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application('federatedfilesharing');
$federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) {
// this is what is thrown when trying to access a non-existing share
throw new \Sabre\DAV\Exception\NotAuthenticated();
}
$share = $authBackend->getShare();
$owner = $share->getShareOwner();
$fileId = $share->getNodeId();
\OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use($share) {
return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE));
});
OC_Util::setupFS($owner);
$ownerView = \OC\Files\Filesystem::getView();
$path = $ownerView->getPath($fileId);
$fileInfo = $ownerView->getFileInfo($path);
$linkCheckPlugin->setFileInfo($fileInfo);
return new \OC\Files\View($ownerView->getAbsolutePath($path));
});
$server->addPlugin($linkCheckPlugin);
// And off we go!
$server->exec();
示例13: setupWrapper
/**
* Setup the storage wrapper callback
*/
public static function setupWrapper()
{
// Set up flock
\OC\Files\Filesystem::addStorageWrapper('oc_flock', function ($mountPoint, $storage) {
/**
* @var Storage $storage
*/
if ($storage->instanceOfStorage('OC\\Files\\Storage\\Local') && !$storage->instanceOfStorage('\\OC\\Files\\Storage\\MappedLocal')) {
return new LockingWrapper(array('storage' => $storage));
} else {
return $storage;
}
});
}