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


PHP Lib\StorageConfig类代码示例

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


在下文中一共展示了StorageConfig类的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: manipulateStorageConfig

 /**
  * @param StorageConfig $storage
  * @param IUser $user
  */
 public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null)
 {
     $user = $storage->getBackendOption('user');
     if ($domain = $storage->getBackendOption('domain')) {
         $storage->setBackendOption('user', $domain . '\\' . $user);
     }
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:11,代码来源:smb.php

示例3: triggerChangeHooks

 /**
  * Triggers signal_create_mount or signal_delete_mount to
  * accomodate for additions/deletions in applicableUsers
  * and applicableGroups fields.
  *
  * @param StorageConfig $oldStorage old storage config
  * @param StorageConfig $newStorage new storage config
  */
 protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $newStorage)
 {
     // if mount point changed, it's like a deletion + creation
     if ($oldStorage->getMountPoint() !== $newStorage->getMountPoint()) {
         $this->triggerHooks($oldStorage, Filesystem::signal_delete_mount);
         $this->triggerHooks($newStorage, Filesystem::signal_create_mount);
         return;
     }
     $userAdditions = array_diff($newStorage->getApplicableUsers(), $oldStorage->getApplicableUsers());
     $userDeletions = array_diff($oldStorage->getApplicableUsers(), $newStorage->getApplicableUsers());
     $groupAdditions = array_diff($newStorage->getApplicableGroups(), $oldStorage->getApplicableGroups());
     $groupDeletions = array_diff($oldStorage->getApplicableGroups(), $newStorage->getApplicableGroups());
     // FIXME: Use as expression in empty once PHP 5.4 support is dropped
     // if no applicable were set, raise a signal for "all"
     $oldApplicableUsers = $oldStorage->getApplicableUsers();
     $oldApplicableGroups = $oldStorage->getApplicableGroups();
     if (empty($oldApplicableUsers) && empty($oldApplicableGroups)) {
         $this->triggerApplicableHooks(Filesystem::signal_delete_mount, $oldStorage->getMountPoint(), \OC_Mount_Config::MOUNT_TYPE_USER, ['all']);
     }
     // trigger delete for removed users
     $this->triggerApplicableHooks(Filesystem::signal_delete_mount, $oldStorage->getMountPoint(), \OC_Mount_Config::MOUNT_TYPE_USER, $userDeletions);
     // trigger delete for removed groups
     $this->triggerApplicableHooks(Filesystem::signal_delete_mount, $oldStorage->getMountPoint(), \OC_Mount_Config::MOUNT_TYPE_GROUP, $groupDeletions);
     // and now add the new users
     $this->triggerApplicableHooks(Filesystem::signal_create_mount, $newStorage->getMountPoint(), \OC_Mount_Config::MOUNT_TYPE_USER, $userAdditions);
     // and now add the new groups
     $this->triggerApplicableHooks(Filesystem::signal_create_mount, $newStorage->getMountPoint(), \OC_Mount_Config::MOUNT_TYPE_GROUP, $groupAdditions);
     // FIXME: Use as expression in empty once PHP 5.4 support is dropped
     // if no applicable, raise a signal for "all"
     $newApplicableUsers = $newStorage->getApplicableUsers();
     $newApplicableGroups = $newStorage->getApplicableGroups();
     if (empty($newApplicableUsers) && empty($newApplicableGroups)) {
         $this->triggerApplicableHooks(Filesystem::signal_create_mount, $newStorage->getMountPoint(), \OC_Mount_Config::MOUNT_TYPE_USER, ['all']);
     }
 }
开发者ID:kenwi,项目名称:core,代码行数:43,代码来源:globalstoragesservice.php

示例4: triggerChangeHooks

 /**
  * Triggers signal_create_mount or signal_delete_mount to
  * accomodate for additions/deletions in applicableUsers
  * and applicableGroups fields.
  *
  * @param StorageConfig $oldStorage old storage data
  * @param StorageConfig $newStorage new storage data
  */
 protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $newStorage)
 {
     // if mount point changed, it's like a deletion + creation
     if ($oldStorage->getMountPoint() !== $newStorage->getMountPoint()) {
         $this->triggerHooks($oldStorage, Filesystem::signal_delete_mount);
         $this->triggerHooks($newStorage, Filesystem::signal_create_mount);
     }
 }
开发者ID:fabricecetic,项目名称:core,代码行数:16,代码来源:userstoragesservice.php

示例5: manipulateStorageConfig

 public function manipulateStorageConfig(StorageConfig &$storage)
 {
     $username_as_share = $storage->getBackendOption('username_as_share') === true;
     if ($username_as_share) {
         $share = '/' . $storage->getBackendOption('user');
         $storage->setBackendOption('share', $share);
     }
 }
开发者ID:hyb148,项目名称:core,代码行数:8,代码来源:smb_oc.php

示例6: manipulateStorageConfig

 protected function manipulateStorageConfig(StorageConfig $storage)
 {
     /** @var AuthMechanism */
     $authMechanism = $storage->getAuthMechanism();
     $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser());
     /** @var Backend */
     $backend = $storage->getBackend();
     $backend->manipulateStorageConfig($storage, $this->userSession->getUser());
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:9,代码来源:userstoragescontroller.php

示例7: manipulateStorageConfig

 private function manipulateStorageConfig(StorageConfig $storage)
 {
     /** @var AuthMechanism */
     $authMechanism = $storage->getAuthMechanism();
     $authMechanism->manipulateStorageConfig($storage);
     /** @var Backend */
     $backend = $storage->getBackend();
     $backend->manipulateStorageConfig($storage);
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:9,代码来源:Verify.php

示例8: manipulateStorageConfig

 public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null)
 {
     $auth = new RSACrypt();
     $auth->setPassword($this->config->getSystemValue('secret', ''));
     if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
         throw new \RuntimeException('unable to load private key');
     }
     $storage->setBackendOption('public_key_auth', $auth);
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:9,代码来源:rsa.php

示例9: 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;
     }
     $mount->setMountOption($key, $value);
     $this->globalService->updateStorage($mount);
 }
开发者ID:kenwi,项目名称:core,代码行数:15,代码来源:option.php

示例10: constructStorage

 /**
  * Construct the storage implementation
  *
  * @param StorageConfig $storageConfig
  * @return Storage
  */
 private function constructStorage(StorageConfig $storageConfig)
 {
     $class = $storageConfig->getBackend()->getStorageClass();
     $storage = new $class($storageConfig->getBackendOptions());
     // auth mechanism should fire first
     $storage = $storageConfig->getBackend()->wrapStorage($storage);
     $storage = $storageConfig->getAuthMechanism()->wrapStorage($storage);
     return $storage;
 }
开发者ID:GrumpyCrouton,项目名称:core,代码行数:15,代码来源:configadapter.php

示例11: manipulateStorageConfig

 public function manipulateStorageConfig(StorageConfig &$storage)
 {
     $encrypted = $this->session->get('password::sessioncredentials/credentials');
     if (!isset($encrypted)) {
         throw new InsufficientDataForMeaningfulAnswerException('No session credentials saved');
     }
     $credentials = json_decode($this->crypto->decrypt($encrypted), true);
     $storage->setBackendOption('user', $this->session->get('loginname'));
     $storage->setBackendOption('password', $credentials['password']);
 }
开发者ID:kenwi,项目名称:core,代码行数:10,代码来源:sessioncredentials.php

示例12: manipulateStorageConfig

 public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null)
 {
     if ($storage->getType() === StorageConfig::MOUNT_TYPE_ADMIN) {
         $uid = '';
     } else {
         $uid = $user->getUID();
     }
     $credentials = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER);
     if (is_array($credentials)) {
         $storage->setBackendOption('user', $credentials['user']);
         $storage->setBackendOption('password', $credentials['password']);
     }
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:13,代码来源:globalauth.php

示例13: manipulateStorageConfig

 public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null)
 {
     if (!isset($user)) {
         throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved');
     }
     $uid = $user->getUID();
     $credentials = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER);
     if (!isset($credentials)) {
         throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved');
     }
     $storage->setBackendOption('user', $credentials['user']);
     $storage->setBackendOption('password', $credentials['password']);
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:13,代码来源:logincredentials.php

示例14: manipulateStorageConfig

 public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null)
 {
     if ($storage->getType() === StorageConfig::MOUNT_TYPE_ADMIN) {
         $uid = '';
     } elseif (is_null($user)) {
         throw new InsufficientDataForMeaningfulAnswerException('No credentials saved');
     } else {
         $uid = $user->getUID();
     }
     $credentials = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER);
     if (is_array($credentials)) {
         $storage->setBackendOption('user', $credentials['user']);
         $storage->setBackendOption('password', $credentials['password']);
     }
 }
开发者ID:ZverAleksey,项目名称:core,代码行数:15,代码来源:globalauth.php

示例15: 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


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