当前位置: 首页>>代码示例>>PHP>>正文


PHP StorageConfig::setMountPoint方法代码示例

本文整理汇总了PHP中OCA\Files_External\Lib\StorageConfig::setMountPoint方法的典型用法代码示例。如果您正苦于以下问题:PHP StorageConfig::setMountPoint方法的具体用法?PHP StorageConfig::setMountPoint怎么用?PHP StorageConfig::setMountPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCA\Files_External\Lib\StorageConfig的用法示例。


在下文中一共展示了StorageConfig::setMountPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testJsonSerialization

 public function testJsonSerialization()
 {
     $backend = $this->getMockBuilder('\\OCA\\Files_External\\Lib\\Backend\\Backend')->disableOriginalConstructor()->getMock();
     $parameter = $this->getMockBuilder('\\OCA\\Files_External\\Lib\\DefinitionParameter')->disableOriginalConstructor()->getMock();
     $parameter->expects($this->once())->method('getType')->willReturn(1);
     $backend->expects($this->once())->method('getParameters')->willReturn(['secure' => $parameter]);
     $backend->method('getIdentifier')->willReturn('storage::identifier');
     $authMech = $this->getMockBuilder('\\OCA\\Files_External\\Lib\\Auth\\AuthMechanism')->disableOriginalConstructor()->getMock();
     $authMech->method('getIdentifier')->willReturn('auth::identifier');
     $storageConfig = new StorageConfig(1);
     $storageConfig->setMountPoint('test');
     $storageConfig->setBackend($backend);
     $storageConfig->setAuthMechanism($authMech);
     $storageConfig->setBackendOptions(['user' => 'test', 'password' => 'password123', 'secure' => '1']);
     $storageConfig->setPriority(128);
     $storageConfig->setApplicableUsers(['user1', 'user2']);
     $storageConfig->setApplicableGroups(['group1', 'group2']);
     $storageConfig->setMountOptions(['preview' => false]);
     $json = $storageConfig->jsonSerialize();
     $this->assertSame(1, $json['id']);
     $this->assertSame('/test', $json['mountPoint']);
     $this->assertSame('storage::identifier', $json['backend']);
     $this->assertSame('auth::identifier', $json['authMechanism']);
     $this->assertSame('test', $json['backendOptions']['user']);
     $this->assertSame('password123', $json['backendOptions']['password']);
     $this->assertSame(true, $json['backendOptions']['secure']);
     $this->assertSame(128, $json['priority']);
     $this->assertSame(['user1', 'user2'], $json['applicableUsers']);
     $this->assertSame(['group1', 'group2'], $json['applicableGroups']);
     $this->assertSame(['preview' => false], $json['mountOptions']);
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:31,代码来源:StorageConfigTest.php

示例2: getMount

 /**
  * @param $id
  * @param $mountPoint
  * @param $backendClass
  * @param string $applicableIdentifier
  * @param array $config
  * @param array $options
  * @param array $users
  * @param array $groups
  * @return StorageConfig
  */
 protected function getMount($id, $mountPoint, $backendClass, $applicableIdentifier = 'password::password', $config = [], $options = [], $users = [], $groups = [])
 {
     $mount = new StorageConfig($id);
     $mount->setMountPoint($mountPoint);
     $mount->setBackendOptions($config);
     $mount->setMountOptions($options);
     $mount->setApplicableUsers($users);
     $mount->setApplicableGroups($groups);
     return $mount;
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:21,代码来源:commandtest.php

示例3: testDeleteStorage

 public function testDeleteStorage()
 {
     $storage = new StorageConfig(255);
     $storage->setMountPoint('mountpoint');
     $storage->setBackendClass('\\OC\\Files\\Storage\\SMB');
     $storage->setBackendOptions(['password' => 'testPassword']);
     $newStorage = $this->service->addStorage($storage);
     $this->assertEquals(1, $newStorage->getId());
     $newStorage = $this->service->removeStorage(1);
     $caught = false;
     try {
         $this->service->getStorage(1);
     } catch (NotFoundException $e) {
         $caught = true;
     }
     $this->assertTrue($caught);
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:17,代码来源:storagesservicetest.php

示例4: testAddOrUpdateStorageDisallowedBackend

 public function testAddOrUpdateStorageDisallowedBackend()
 {
     $backend = $this->getBackendMock();
     $backend->method('isVisibleFor')->with(BackendService::VISIBILITY_PERSONAL)->willReturn(false);
     $authMech = $this->getAuthMechMock();
     $storageConfig = new StorageConfig(1);
     $storageConfig->setMountPoint('mount');
     $storageConfig->setBackend($backend);
     $storageConfig->setAuthMechanism($authMech);
     $storageConfig->setBackendOptions([]);
     $this->service->expects($this->exactly(2))->method('createStorage')->will($this->returnValue($storageConfig));
     $this->service->expects($this->never())->method('addStorage');
     $this->service->expects($this->never())->method('updateStorage');
     $response = $this->controller->create('mount', '\\OC\\Files\\Storage\\SMB', '\\Auth\\Mechanism', array(), [], [], [], null);
     $this->assertEquals(Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus());
     $response = $this->controller->update(1, 'mount', '\\OC\\Files\\Storage\\SMB', '\\Auth\\Mechanism', array(), [], [], [], null);
     $this->assertEquals(Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus());
 }
开发者ID:evanjt,项目名称:core,代码行数:18,代码来源:userstoragescontrollertest.php

示例5: testJsonSerialization

 public function testJsonSerialization()
 {
     $storageConfig = new StorageConfig(1);
     $storageConfig->setMountPoint('test');
     $storageConfig->setBackendClass('\\OC\\Files\\Storage\\SMB');
     $storageConfig->setBackendOptions(['user' => 'test', 'password' => 'password123']);
     $storageConfig->setPriority(128);
     $storageConfig->setApplicableUsers(['user1', 'user2']);
     $storageConfig->setApplicableGroups(['group1', 'group2']);
     $storageConfig->setMountOptions(['preview' => false]);
     $json = $storageConfig->jsonSerialize();
     $this->assertEquals(1, $json['id']);
     $this->assertEquals('/test', $json['mountPoint']);
     $this->assertEquals('\\OC\\Files\\Storage\\SMB', $json['backendClass']);
     $this->assertEquals('test', $json['backendOptions']['user']);
     $this->assertEquals('password123', $json['backendOptions']['password']);
     $this->assertEquals(128, $json['priority']);
     $this->assertEquals(['user1', 'user2'], $json['applicableUsers']);
     $this->assertEquals(['group1', 'group2'], $json['applicableGroups']);
     $this->assertEquals(['preview' => false], $json['mountOptions']);
 }
开发者ID:samj1912,项目名称:repo,代码行数:21,代码来源:storageconfigtest.php

示例6: update

 /**
  * Update an external storage entry.
  *
  * @param int $id storage id
  * @param string $mountPoint storage mount point
  * @param string $backendClass backend class name
  * @param array $backendOptions backend-specific options
  * @param array $mountOptions mount-specific options
  * @param array $applicableUsers users for which to mount the storage
  * @param array $applicableGroups groups for which to mount the storage
  * @param int $priority priority
  *
  * @return DataResponse
  */
 public function update($id, $mountPoint, $backendClass, $backendOptions, $mountOptions, $applicableUsers, $applicableGroups, $priority)
 {
     $storage = new StorageConfig($id);
     $storage->setMountPoint($mountPoint);
     $storage->setBackendClass($backendClass);
     $storage->setBackendOptions($backendOptions);
     $storage->setMountOptions($mountOptions);
     $storage->setApplicableUsers($applicableUsers);
     $storage->setApplicableGroups($applicableGroups);
     $storage->setPriority($priority);
     $response = $this->validate($storage);
     if (!empty($response)) {
         return $response;
     }
     try {
         $storage = $this->service->updateStorage($storage);
     } catch (NotFoundException $e) {
         return new DataResponse(['message' => (string) $this->l10n->t('Storage with id "%i" not found', array($id))], Http::STATUS_NOT_FOUND);
     }
     $this->updateStorageStatus($storage);
     return new DataResponse($storage, Http::STATUS_OK);
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:36,代码来源:globalstoragescontroller.php

示例7: getAllStorages

 /**
  * Read the external storages config
  *
  * @return StorageConfig[] map of storage id to storage config
  */
 public function getAllStorages()
 {
     $mountPoints = $this->readLegacyConfig();
     /**
      * Here is the how the horribly messy mount point array looks like
      * from the mount.json file:
      *
      * $storageOptions = $mountPoints[$mountType][$applicable][$mountPath]
      *
      * - $mountType is either "user" or "group"
      * - $applicable is the name of a user or group (or the current user for personal mounts)
      * - $mountPath is the mount point path (where the storage must be mounted)
      * - $storageOptions is a map of storage options:
      *     - "priority": storage priority
      *     - "backend": backend identifier
      *     - "class": LEGACY backend class name
      *     - "options": backend-specific options
      *     - "authMechanism": authentication mechanism identifier
      *     - "mountOptions": mount-specific options (ex: disable previews, scanner, etc)
      */
     // group by storage id
     /** @var StorageConfig[] $storages */
     $storages = [];
     // for storages without id (legacy), group by config hash for
     // later processing
     $storagesWithConfigHash = [];
     foreach ($mountPoints as $mountType => $applicables) {
         foreach ($applicables as $applicable => $mountPaths) {
             foreach ($mountPaths as $rootMountPath => $storageOptions) {
                 $currentStorage = null;
                 /**
                  * Flag whether the config that was read already has an id.
                  * If not, it will use a config hash instead and generate
                  * a proper id later
                  *
                  * @var boolean
                  */
                 $hasId = false;
                 // the root mount point is in the format "/$user/files/the/mount/point"
                 // we remove the "/$user/files" prefix
                 $parts = explode('/', ltrim($rootMountPath, '/'), 3);
                 if (count($parts) < 3) {
                     // something went wrong, skip
                     \OCP\Util::writeLog('files_external', 'Could not parse mount point "' . $rootMountPath . '"', \OCP\Util::ERROR);
                     continue;
                 }
                 $relativeMountPath = rtrim($parts[2], '/');
                 // note: we cannot do this after the loop because the decrypted config
                 // options might be needed for the config hash
                 $storageOptions['options'] = \OC_Mount_Config::decryptPasswords($storageOptions['options']);
                 if (!isset($storageOptions['backend'])) {
                     $storageOptions['backend'] = $storageOptions['class'];
                     // legacy compat
                 }
                 if (!isset($storageOptions['authMechanism'])) {
                     $storageOptions['authMechanism'] = null;
                     // ensure config hash works
                 }
                 if (isset($storageOptions['id'])) {
                     $configId = (int) $storageOptions['id'];
                     if (isset($storages[$configId])) {
                         $currentStorage = $storages[$configId];
                     }
                     $hasId = true;
                 } else {
                     // missing id in legacy config, need to generate
                     // but at this point we don't know the max-id, so use
                     // first group it by config hash
                     $storageOptions['mountpoint'] = $rootMountPath;
                     $configId = \OC_Mount_Config::makeConfigHash($storageOptions);
                     if (isset($storagesWithConfigHash[$configId])) {
                         $currentStorage = $storagesWithConfigHash[$configId];
                     }
                 }
                 if (is_null($currentStorage)) {
                     // create new
                     $currentStorage = new StorageConfig($configId);
                     $currentStorage->setMountPoint($relativeMountPath);
                 }
                 try {
                     $this->populateStorageConfigWithLegacyOptions($currentStorage, $mountType, $applicable, $storageOptions);
                     if ($hasId) {
                         $storages[$configId] = $currentStorage;
                     } else {
                         $storagesWithConfigHash[$configId] = $currentStorage;
                     }
                 } catch (\UnexpectedValueException $e) {
                     // don't die if a storage backend doesn't exist
                     \OCP\Util::writeLog('files_external', 'Could not load storage: "' . $e->getMessage() . '"', \OCP\Util::ERROR);
                 }
             }
         }
     }
     // convert parameter values
     foreach ($storages as $storage) {
//.........这里部分代码省略.........
开发者ID:stweil,项目名称:owncloud-core,代码行数:101,代码来源:legacystoragesservice.php

示例8: createStorage

 /**
  * Create a storage from its parameters
  *
  * @param string $mountPoint storage mount point
  * @param string $backendIdentifier backend identifier
  * @param string $authMechanismIdentifier authentication mechanism identifier
  * @param array $backendOptions backend-specific options
  * @param array|null $mountOptions mount-specific options
  * @param array|null $applicableUsers users for which to mount the storage
  * @param array|null $applicableGroups groups for which to mount the storage
  * @param int|null $priority priority
  *
  * @return StorageConfig
  */
 public function createStorage($mountPoint, $backendIdentifier, $authMechanismIdentifier, $backendOptions, $mountOptions = null, $applicableUsers = null, $applicableGroups = null, $priority = null)
 {
     $backend = $this->backendService->getBackend($backendIdentifier);
     if (!$backend) {
         throw new \InvalidArgumentException('Unable to get backend for ' . $backendIdentifier);
     }
     $authMechanism = $this->backendService->getAuthMechanism($authMechanismIdentifier);
     if (!$authMechanism) {
         throw new \InvalidArgumentException('Unable to get authentication mechanism for ' . $authMechanismIdentifier);
     }
     $newStorage = new StorageConfig();
     $newStorage->setMountPoint($mountPoint);
     $newStorage->setBackend($backend);
     $newStorage->setAuthMechanism($authMechanism);
     $newStorage->setBackendOptions($backendOptions);
     if (isset($mountOptions)) {
         $newStorage->setMountOptions($mountOptions);
     }
     if (isset($applicableUsers)) {
         $newStorage->setApplicableUsers($applicableUsers);
     }
     if (isset($applicableGroups)) {
         $newStorage->setApplicableGroups($applicableGroups);
     }
     if (isset($priority)) {
         $newStorage->setPriority($priority);
     }
     return $newStorage;
 }
开发者ID:loulancn,项目名称:core,代码行数:43,代码来源:storagesservice.php

示例9: testGetStoragesAuthMechanismNotVisible

 public function testGetStoragesAuthMechanismNotVisible()
 {
     $backend = $this->backendService->getBackend('identifier:\\OCA\\Files_External\\Lib\\Backend\\SMB');
     $backend->method('isVisibleFor')->with($this->service->getVisibilityType())->willReturn(true);
     $authMechanism = $this->backendService->getAuthMechanism('identifier:\\Auth\\Mechanism');
     $authMechanism->expects($this->once())->method('isVisibleFor')->with($this->service->getVisibilityType())->willReturn(false);
     $storage = new StorageConfig(255);
     $storage->setMountPoint('mountpoint');
     $storage->setBackend($backend);
     $storage->setAuthMechanism($authMechanism);
     $storage->setBackendOptions(['password' => 'testPassword']);
     $newStorage = $this->service->addStorage($storage);
     $this->assertCount(1, $this->service->getAllStorages());
     $this->assertEmpty($this->service->getStorages());
 }
开发者ID:evanjt,项目名称:core,代码行数:15,代码来源:storagesservicetest.php

示例10: parseData

 private function parseData(array $data)
 {
     $mount = new StorageConfig($data['mount_id']);
     $mount->setMountPoint($data['mount_point']);
     $mount->setBackend($this->getBackendByClass($data['storage']));
     $authBackend = $this->backendService->getAuthMechanism($data['authentication_type']);
     $mount->setAuthMechanism($authBackend);
     $mount->setBackendOptions($data['configuration']);
     $mount->setMountOptions($data['options']);
     $mount->setApplicableUsers(isset($data['applicable_users']) ? $data['applicable_users'] : []);
     $mount->setApplicableGroups(isset($data['applicable_groups']) ? $data['applicable_groups'] : []);
     return $mount;
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:13,代码来源:Import.php

示例11: setOption

 /**
  * @param StorageConfig $mount
  * @param string $key
  * @param string $value
  * @param OutputInterface $output
  */
 protected function setOption(StorageConfig $mount, $key, $value, OutputInterface $output)
 {
     $decoded = json_decode($value, true);
     if (!is_null($decoded)) {
         $value = $decoded;
     }
     if ($key === 'mountpoint' || $key === 'mount_point') {
         $mount->setMountPoint($value);
     } else {
         $mount->setBackendOption($key, $value);
     }
     $this->globalService->updateStorage($mount);
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:19,代码来源:Config.php

示例12: testUpdateStorageMountPoint

 public function testUpdateStorageMountPoint()
 {
     $backend = $this->backendService->getBackend('identifier:\\OCA\\Files_External\\Lib\\Backend\\SMB');
     $authMechanism = $this->backendService->getAuthMechanism('identifier:\\Auth\\Mechanism');
     $storage = new StorageConfig();
     $storage->setMountPoint('mountpoint');
     $storage->setBackend($backend);
     $storage->setAuthMechanism($authMechanism);
     $storage->setBackendOptions(['password' => 'testPassword']);
     $savedStorage = $this->service->addStorage($storage);
     $newAuthMechanism = $this->backendService->getAuthMechanism('identifier:\\Other\\Auth\\Mechanism');
     $updatedStorage = new StorageConfig($savedStorage->getId());
     $updatedStorage->setMountPoint('mountpoint2');
     $updatedStorage->setBackend($backend);
     $updatedStorage->setAuthMechanism($newAuthMechanism);
     $updatedStorage->setBackendOptions(['password' => 'password2']);
     $this->service->updateStorage($updatedStorage);
     $savedStorage = $this->service->getStorage($updatedStorage->getId());
     $this->assertEquals('/mountpoint2', $savedStorage->getMountPoint());
     $this->assertEquals($newAuthMechanism, $savedStorage->getAuthMechanism());
     $this->assertEquals('password2', $savedStorage->getBackendOption('password'));
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:22,代码来源:storagesservicetest.php

示例13: testGetUniqueStorages

 /**
  * @dataProvider getUniqueStoragesProvider
  */
 public function testGetUniqueStorages($priority1, $applicableUsers1, $applicableGroups1, $priority2, $applicableUsers2, $applicableGroups2, $expectedPrecedence)
 {
     $backend = $this->backendService->getBackend('identifier:\\OCA\\Files_External\\Lib\\Backend\\SMB');
     $authMechanism = $this->backendService->getAuthMechanism('identifier:\\Auth\\Mechanism');
     $storage1 = new StorageConfig();
     $storage1->setMountPoint('mountpoint');
     $storage1->setBackend($backend);
     $storage1->setAuthMechanism($authMechanism);
     $storage1->setBackendOptions(['password' => 'testPassword']);
     $storage1->setPriority($priority1);
     $storage1->setApplicableUsers($applicableUsers1);
     $storage1->setApplicableGroups($applicableGroups1);
     $storage1 = $this->globalStoragesService->addStorage($storage1);
     $storage2 = new StorageConfig();
     $storage2->setMountPoint('mountpoint');
     $storage2->setBackend($backend);
     $storage2->setAuthMechanism($authMechanism);
     $storage2->setBackendOptions(['password' => 'testPassword']);
     $storage2->setPriority($priority2);
     $storage2->setApplicableUsers($applicableUsers2);
     $storage2->setApplicableGroups($applicableGroups2);
     $storage2 = $this->globalStoragesService->addStorage($storage2);
     $storages = $this->service->getUniqueStorages();
     $this->assertCount(1, $storages);
     if ($expectedPrecedence === 1) {
         $this->assertArrayHasKey($storage1->getID(), $storages);
     } elseif ($expectedPrecedence === 2) {
         $this->assertArrayHasKey($storage2->getID(), $storages);
     }
 }
开发者ID:unrealbato,项目名称:core,代码行数:33,代码来源:userglobalstoragesservicetest.php

示例14: testGetAdminStorage

 /**
  * @expectedException \OCA\Files_External\NotFoundException
  */
 public function testGetAdminStorage()
 {
     $backend = $this->backendService->getBackend('identifier:\\OCA\\Files_External\\Lib\\Backend\\SMB');
     $authMechanism = $this->backendService->getAuthMechanism('identifier:\\Auth\\Mechanism');
     $storage = new StorageConfig();
     $storage->setMountPoint('mountpoint');
     $storage->setBackend($backend);
     $storage->setAuthMechanism($authMechanism);
     $storage->setBackendOptions(['password' => 'testPassword']);
     $storage->setApplicableUsers([$this->userId]);
     $newStorage = $this->globalStoragesService->addStorage($storage);
     $this->assertInstanceOf('\\OCA\\Files_External\\Lib\\StorageConfig', $this->globalStoragesService->getStorage($newStorage->getId()));
     $this->service->getStorage($newStorage->getId());
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:17,代码来源:UserStoragesServiceTest.php

示例15: testGetStorage

 public function testGetStorage()
 {
     $storageConfig = new StorageConfig(1);
     $storageConfig->setMountPoint('test');
     $storageConfig->setBackendClass('\\OC\\Files\\Storage\\SMB');
     $storageConfig->setBackendOptions(['user' => 'test', 'password', 'password123']);
     $storageConfig->setMountOptions(['priority' => false]);
     $this->service->expects($this->once())->method('getStorage')->with(1)->will($this->returnValue($storageConfig));
     $response = $this->controller->show(1);
     $this->assertEquals(Http::STATUS_OK, $response->getStatus());
     $this->assertEquals($storageConfig, $response->getData());
 }
开发者ID:samj1912,项目名称:repo,代码行数:12,代码来源:storagescontrollertest.php


注:本文中的OCA\Files_External\Lib\StorageConfig::setMountPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。