apps/files_external/lib/Service/LegacyStoragesService.php
/**
	 * 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
	 */
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
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'; 
		}
		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;
	}
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' ; } 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 ; }
Copy legacy storage options into the given storage config object.
Copy legacy storage options into the given storage config object .
// to make error handling easier