本文整理汇总了PHP中OCA\Files_External\Lib\StorageConfig::setMountOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP StorageConfig::setMountOptions方法的具体用法?PHP StorageConfig::setMountOptions怎么用?PHP StorageConfig::setMountOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCA\Files_External\Lib\StorageConfig
的用法示例。
在下文中一共展示了StorageConfig::setMountOptions方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: populateStorageConfigWithLegacyOptions
/**
* Copy legacy storage options into the given storage config object.
*
* @param StorageConfig $storageConfig storage config to populate
* @param string $mountType mount type
* @param string $applicable applicable user or group
* @param array $storageOptions legacy storage options
*
* @return StorageConfig populated storage config
*/
protected function populateStorageConfigWithLegacyOptions(&$storageConfig, $mountType, $applicable, $storageOptions)
{
$storageConfig->setBackendClass($storageOptions['class']);
$storageConfig->setBackendOptions($storageOptions['options']);
if (isset($storageOptions['mountOptions'])) {
$storageConfig->setMountOptions($storageOptions['mountOptions']);
}
if (isset($storageOptions['priority'])) {
$storageConfig->setPriority($storageOptions['priority']);
}
if ($mountType === \OC_Mount_Config::MOUNT_TYPE_USER) {
$applicableUsers = $storageConfig->getApplicableUsers();
if ($applicable !== 'all') {
$applicableUsers[] = $applicable;
$storageConfig->setApplicableUsers($applicableUsers);
}
} else {
if ($mountType === \OC_Mount_Config::MOUNT_TYPE_GROUP) {
$applicableGroups = $storageConfig->getApplicableGroups();
$applicableGroups[] = $applicable;
$storageConfig->setApplicableGroups($applicableGroups);
}
}
return $storageConfig;
}
示例2: 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']);
}
示例3: 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;
}
示例4: populateStorageConfigWithLegacyOptions
/**
* Copy legacy storage options into the given storage config object.
*
* @param StorageConfig $storageConfig storage config to populate
* @param string $mountType mount type
* @param string $applicable applicable user or group
* @param array $storageOptions legacy storage options
*
* @return StorageConfig populated storage config
*/
protected function populateStorageConfigWithLegacyOptions(&$storageConfig, $mountType, $applicable, $storageOptions)
{
$backend = $this->backendService->getBackend($storageOptions['backend']);
if (!$backend) {
throw new \UnexpectedValueException('Invalid backend ' . $storageOptions['backend']);
}
$storageConfig->setBackend($backend);
if (isset($storageOptions['authMechanism']) && $storageOptions['authMechanism'] !== 'builtin::builtin') {
$authMechanism = $this->backendService->getAuthMechanism($storageOptions['authMechanism']);
} else {
$authMechanism = $backend->getLegacyAuthMechanism($storageOptions);
$storageOptions['authMechanism'] = 'null';
// to make error handling easier
}
if (!$authMechanism) {
throw new \UnexpectedValueException('Invalid authentication mechanism ' . $storageOptions['authMechanism']);
}
$storageConfig->setAuthMechanism($authMechanism);
$storageConfig->setBackendOptions($storageOptions['options']);
if (isset($storageOptions['mountOptions'])) {
$storageConfig->setMountOptions($storageOptions['mountOptions']);
}
if (!isset($storageOptions['priority'])) {
$storageOptions['priority'] = $backend->getPriority();
}
$storageConfig->setPriority($storageOptions['priority']);
if ($mountType === \OC_Mount_Config::MOUNT_TYPE_USER) {
$applicableUsers = $storageConfig->getApplicableUsers();
if ($applicable !== 'all') {
$applicableUsers[] = $applicable;
$storageConfig->setApplicableUsers($applicableUsers);
}
} else {
if ($mountType === \OC_Mount_Config::MOUNT_TYPE_GROUP) {
$applicableGroups = $storageConfig->getApplicableGroups();
$applicableGroups[] = $applicable;
$storageConfig->setApplicableGroups($applicableGroups);
}
}
return $storageConfig;
}
示例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']);
}
示例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);
}
示例7: makeStorageConfig
/**
* Creates a StorageConfig instance based on array data
*
* @param array data
*
* @return StorageConfig storage config instance
*/
protected function makeStorageConfig($data)
{
$storage = new StorageConfig();
if (isset($data['id'])) {
$storage->setId($data['id']);
}
$storage->setMountPoint($data['mountPoint']);
$storage->setBackendClass($data['backendClass']);
$storage->setBackendOptions($data['backendOptions']);
if (isset($data['applicableUsers'])) {
$storage->setApplicableUsers($data['applicableUsers']);
}
if (isset($data['applicableGroups'])) {
$storage->setApplicableGroups($data['applicableGroups']);
}
if (isset($data['priority'])) {
$storage->setPriority($data['priority']);
}
if (isset($data['mountOptions'])) {
$storage->setMountOptions($data['mountOptions']);
}
return $storage;
}
示例8: makeStorageConfig
/**
* Creates a StorageConfig instance based on array data
*
* @param array data
*
* @return StorageConfig storage config instance
*/
protected function makeStorageConfig($data)
{
$storage = new StorageConfig();
if (isset($data['id'])) {
$storage->setId($data['id']);
}
$storage->setMountPoint($data['mountPoint']);
if (!isset($data['backend'])) {
// data providers are run before $this->backendService is initialised
// so $data['backend'] can be specified directly
$data['backend'] = $this->backendService->getBackend($data['backendIdentifier']);
}
if (!isset($data['backend'])) {
throw new \Exception('oops, no backend');
}
if (!isset($data['authMechanism'])) {
$data['authMechanism'] = $this->backendService->getAuthMechanism($data['authMechanismIdentifier']);
}
if (!isset($data['authMechanism'])) {
throw new \Exception('oops, no auth mechanism');
}
$storage->setBackend($data['backend']);
$storage->setAuthMechanism($data['authMechanism']);
$storage->setBackendOptions($data['backendOptions']);
if (isset($data['applicableUsers'])) {
$storage->setApplicableUsers($data['applicableUsers']);
}
if (isset($data['applicableGroups'])) {
$storage->setApplicableGroups($data['applicableGroups']);
}
if (isset($data['priority'])) {
$storage->setPriority($data['priority']);
}
if (isset($data['mountOptions'])) {
$storage->setMountOptions($data['mountOptions']);
}
return $storage;
}
示例9: 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;
}
示例10: sanitizeStorage
/**
* Remove sensitive data from a StorageConfig before returning it to the user
*
* @param StorageConfig $storage
*/
protected function sanitizeStorage(StorageConfig $storage)
{
$storage->setBackendOptions([]);
$storage->setMountOptions([]);
}
示例11: 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());
}
示例12: sanitizeStorage
/**
* Remove sensitive data from a StorageConfig before returning it to the user
*
* @param StorageConfig $storage
*/
protected function sanitizeStorage(StorageConfig $storage)
{
$storage->setBackendOptions([]);
$storage->setMountOptions([]);
if ($storage->getAuthMechanism() instanceof IUserProvided) {
try {
$storage->getAuthMechanism()->manipulateStorageConfig($storage, $this->userSession->getUser());
} catch (InsufficientDataForMeaningfulAnswerException $e) {
// not configured yet
}
}
}
示例13: testGetStorage
public function testGetStorage()
{
$backend = $this->getBackendMock();
$authMech = $this->getAuthMechMock();
$storageConfig = new StorageConfig(1);
$storageConfig->setMountPoint('test');
$storageConfig->setBackend($backend);
$storageConfig->setAuthMechanism($authMech);
$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());
}
示例14: 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;
}