本文整理汇总了PHP中OCA\Files_External\Lib\StorageConfig::getBackendOption方法的典型用法代码示例。如果您正苦于以下问题:PHP StorageConfig::getBackendOption方法的具体用法?PHP StorageConfig::getBackendOption怎么用?PHP StorageConfig::getBackendOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCA\Files_External\Lib\StorageConfig
的用法示例。
在下文中一共展示了StorageConfig::getBackendOption方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例3: 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);
}
示例4: getOption
/**
* @param StorageConfig $mount
* @param string $key
* @param OutputInterface $output
*/
protected function getOption(StorageConfig $mount, $key, OutputInterface $output)
{
$value = $mount->getBackendOption($key);
if (!is_string($value)) {
// show bools and objects correctly
$value = json_encode($value);
}
$output->writeln($value);
}
示例5: prepareStorageConfig
/**
* Process storage ready for mounting
*
* @param StorageConfig $storage
* @param IUser $user
*/
private function prepareStorageConfig(StorageConfig &$storage, IUser $user)
{
foreach ($storage->getBackendOptions() as $option => $value) {
$storage->setBackendOption($option, \OC_Mount_Config::setUserVars($user->getUID(), $value));
}
$objectStore = $storage->getBackendOption('objectstore');
if ($objectStore) {
$objectClass = $objectStore['class'];
$storage->setBackendOption('objectstore', new $objectClass($objectStore));
}
$storage->getAuthMechanism()->manipulateStorageConfig($storage);
$storage->getBackend()->manipulateStorageConfig($storage);
}
示例6: getOption
/**
* @param StorageConfig $mount
* @param string $key
* @param OutputInterface $output
*/
protected function getOption(StorageConfig $mount, $key, OutputInterface $output)
{
if ($key === 'mountpoint' || $key === 'mount_point') {
$value = $mount->getMountPoint();
} else {
$value = $mount->getBackendOption($key);
}
if (!is_string($value)) {
// show bools and objects correctly
$value = json_encode($value);
}
$output->writeln($value);
}
示例7: prepareStorageConfig
/**
* Process storage ready for mounting
*
* @param StorageConfig $storage
* @param IUser $user
*/
private function prepareStorageConfig(StorageConfig &$storage, IUser $user)
{
foreach ($storage->getBackendOptions() as $option => $value) {
$storage->setBackendOption($option, \OC_Mount_Config::setUserVars($user->getUID(), $value));
}
$objectStore = $storage->getBackendOption('objectstore');
if ($objectStore) {
$objectClass = $objectStore['class'];
if (!is_subclass_of($objectClass, '\\OCP\\Files\\ObjectStore\\IObjectStore')) {
throw new \InvalidArgumentException('Invalid object store');
}
$storage->setBackendOption('objectstore', new $objectClass($objectStore));
}
$storage->getAuthMechanism()->manipulateStorageConfig($storage);
$storage->getBackend()->manipulateStorageConfig($storage);
}
示例8: validate
/**
* Validate storage config
*
* @param StorageConfig $storage storage config
*
* @return DataResponse|null returns response in case of validation error
*/
protected function validate(StorageConfig $storage)
{
$mountPoint = $storage->getMountPoint();
if ($mountPoint === '' || $mountPoint === '/') {
return new DataResponse(array('message' => (string) $this->l10n->t('Invalid mount point')), Http::STATUS_UNPROCESSABLE_ENTITY);
}
// TODO: validate that other attrs are set
if ($storage->getBackendOption('objectstore')) {
// objectstore must not be sent from client side
return new DataResponse(array('message' => (string) $this->l10n->t('Objectstore forbidden')), Http::STATUS_UNPROCESSABLE_ENTITY);
}
$backends = \OC_Mount_Config::getBackends();
if (!isset($backends[$storage->getBackendClass()])) {
// invalid backend
return new DataResponse(array('message' => (string) $this->l10n->t('Invalid storage backend "%s"', array($storage->getBackendClass()))), Http::STATUS_UNPROCESSABLE_ENTITY);
}
return null;
}
示例9: validate
/**
* Validate storage config
*
* @param StorageConfig $storage storage config
*
* @return DataResponse|null returns response in case of validation error
*/
protected function validate(StorageConfig $storage)
{
$mountPoint = $storage->getMountPoint();
if ($mountPoint === '' || $mountPoint === '/') {
return new DataResponse(array('message' => (string) $this->l10n->t('Invalid mount point')), Http::STATUS_UNPROCESSABLE_ENTITY);
}
if ($storage->getBackendOption('objectstore')) {
// objectstore must not be sent from client side
return new DataResponse(array('message' => (string) $this->l10n->t('Objectstore forbidden')), Http::STATUS_UNPROCESSABLE_ENTITY);
}
/** @var Backend */
$backend = $storage->getBackend();
/** @var AuthMechanism */
$authMechanism = $storage->getAuthMechanism();
if ($backend->checkDependencies()) {
// invalid backend
return new DataResponse(array('message' => (string) $this->l10n->t('Invalid storage backend "%s"', [$backend->getIdentifier()])), Http::STATUS_UNPROCESSABLE_ENTITY);
}
if (!$backend->isVisibleFor($this->service->getVisibilityType())) {
// not permitted to use backend
return new DataResponse(array('message' => (string) $this->l10n->t('Not permitted to use backend "%s"', [$backend->getIdentifier()])), Http::STATUS_UNPROCESSABLE_ENTITY);
}
if (!$authMechanism->isVisibleFor($this->service->getVisibilityType())) {
// not permitted to use auth mechanism
return new DataResponse(array('message' => (string) $this->l10n->t('Not permitted to use authentication mechanism "%s"', [$authMechanism->getIdentifier()])), Http::STATUS_UNPROCESSABLE_ENTITY);
}
if (!$backend->validateStorage($storage)) {
// unsatisfied parameters
return new DataResponse(array('message' => (string) $this->l10n->t('Unsatisfied backend parameters')), Http::STATUS_UNPROCESSABLE_ENTITY);
}
if (!$authMechanism->validateStorage($storage)) {
// unsatisfied parameters
return new DataResponse(['message' => (string) $this->l10n->t('Unsatisfied authentication mechanism parameters')], Http::STATUS_UNPROCESSABLE_ENTITY);
}
return null;
}
示例10: validateStorageDefinition
/**
* Check if parameters are satisfied in a StorageConfig
*
* @param StorageConfig $storage
* @return bool
*/
public function validateStorageDefinition(StorageConfig $storage)
{
foreach ($this->getParameters() as $name => $parameter) {
$value = $storage->getBackendOption($name);
if (!is_null($value) || !$parameter->isOptional()) {
if (!$parameter->validateValue($value)) {
return false;
}
$storage->setBackendOption($name, $value);
}
}
return true;
}