Fix PHPDoc in files_external, add missing tag
Fix various PHPDoc issues in external storage app. Added missing NoAdminRequired tag
This commit is contained in:
parent
847880803e
commit
e5e30924b1
8 changed files with 77 additions and 25 deletions
|
@ -23,9 +23,8 @@
|
||||||
namespace OCA\Files_External\Appinfo;
|
namespace OCA\Files_External\Appinfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var $this OC\Route\Router
|
* @var $this \OC\Route\Router
|
||||||
**/
|
**/
|
||||||
|
|
||||||
$application = new Application();
|
$application = new Application();
|
||||||
$application->registerRoutes(
|
$application->registerRoutes(
|
||||||
$this,
|
$this,
|
||||||
|
|
|
@ -23,6 +23,9 @@ use \OCA\Files_external\Service\GlobalStoragesService;
|
||||||
use \OCA\Files_external\NotFoundException;
|
use \OCA\Files_external\NotFoundException;
|
||||||
use \OCA\Files_external\Lib\StorageConfig;
|
use \OCA\Files_external\Lib\StorageConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Global storages controller
|
||||||
|
*/
|
||||||
class GlobalStoragesController extends StoragesController {
|
class GlobalStoragesController extends StoragesController {
|
||||||
/**
|
/**
|
||||||
* Creates a new global storages controller.
|
* Creates a new global storages controller.
|
||||||
|
@ -151,4 +154,3 @@ class GlobalStoragesController extends StoragesController {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,14 +23,21 @@ use \OCA\Files_external\Service\StoragesService;
|
||||||
use \OCA\Files_external\NotFoundException;
|
use \OCA\Files_external\NotFoundException;
|
||||||
use \OCA\Files_external\Lib\StorageConfig;
|
use \OCA\Files_external\Lib\StorageConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for storages controllers
|
||||||
|
*/
|
||||||
abstract class StoragesController extends Controller {
|
abstract class StoragesController extends Controller {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* L10N service
|
||||||
|
*
|
||||||
* @var IL10N
|
* @var IL10N
|
||||||
*/
|
*/
|
||||||
protected $l10n;
|
protected $l10n;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Storages service
|
||||||
|
*
|
||||||
* @var StoragesService
|
* @var StoragesService
|
||||||
*/
|
*/
|
||||||
protected $service;
|
protected $service;
|
||||||
|
@ -94,7 +101,7 @@ abstract class StoragesController extends Controller {
|
||||||
* Note that this operation can be time consuming depending
|
* Note that this operation can be time consuming depending
|
||||||
* on whether the remote storage is available or not.
|
* on whether the remote storage is available or not.
|
||||||
*
|
*
|
||||||
* @param StorageConfig $storage
|
* @param StorageConfig $storage storage configuration
|
||||||
*/
|
*/
|
||||||
protected function updateStorageStatus(StorageConfig &$storage) {
|
protected function updateStorageStatus(StorageConfig &$storage) {
|
||||||
// update status (can be time-consuming)
|
// update status (can be time-consuming)
|
||||||
|
|
|
@ -23,6 +23,9 @@ use \OCA\Files_external\Service\UserStoragesService;
|
||||||
use \OCA\Files_external\NotFoundException;
|
use \OCA\Files_external\NotFoundException;
|
||||||
use \OCA\Files_external\Lib\StorageConfig;
|
use \OCA\Files_external\Lib\StorageConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User storages controller
|
||||||
|
*/
|
||||||
class UserStoragesController extends StoragesController {
|
class UserStoragesController extends StoragesController {
|
||||||
/**
|
/**
|
||||||
* Creates a new user storages controller.
|
* Creates a new user storages controller.
|
||||||
|
@ -76,8 +79,11 @@ class UserStoragesController extends StoragesController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Return storage
|
||||||
|
*
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @{inheritdoc}
|
*
|
||||||
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function show($id) {
|
public function show($id) {
|
||||||
return parent::show($id);
|
return parent::show($id);
|
||||||
|
@ -131,6 +137,8 @@ class UserStoragesController extends StoragesController {
|
||||||
* @param array $mountOptions backend-specific mount options
|
* @param array $mountOptions backend-specific mount options
|
||||||
*
|
*
|
||||||
* @return DataResponse
|
* @return DataResponse
|
||||||
|
*
|
||||||
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
public function update(
|
public function update(
|
||||||
$id,
|
$id,
|
||||||
|
@ -171,11 +179,13 @@ class UserStoragesController extends StoragesController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Delete storage
|
||||||
|
*
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
|
*
|
||||||
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function destroy($id) {
|
public function destroy($id) {
|
||||||
return parent::destroy($id);
|
return parent::destroy($id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,51 +14,71 @@ namespace OCA\Files_external\Lib;
|
||||||
class StorageConfig implements \JsonSerializable {
|
class StorageConfig implements \JsonSerializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Storage config id
|
||||||
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Backend class name
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $backendClass;
|
private $backendClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Backend options
|
||||||
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $backendOptions = [];
|
private $backendOptions = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Mount point path, relative to the user's "files" folder
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $mountPoint;
|
private $mountPoint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Storage status
|
||||||
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $status;
|
private $status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Priority
|
||||||
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $priority;
|
private $priority;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* List of users who have access to this storage
|
||||||
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $applicableUsers = [];
|
private $applicableUsers = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* List of groups that have access to this storage
|
||||||
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $applicableGroups = [];
|
private $applicableGroups = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Mount-specific options
|
||||||
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $mountOptions = [];
|
private $mountOptions = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Creates a storage config
|
||||||
|
*
|
||||||
* @param int|null $id config id or null for a new config
|
* @param int|null $id config id or null for a new config
|
||||||
*/
|
*/
|
||||||
public function __construct($id = null) {
|
public function __construct($id = null) {
|
||||||
|
@ -77,7 +97,7 @@ class StorageConfig implements \JsonSerializable {
|
||||||
/**
|
/**
|
||||||
* Sets the configuration id
|
* Sets the configuration id
|
||||||
*
|
*
|
||||||
* @param int configuration id
|
* @param int $id configuration id
|
||||||
*/
|
*/
|
||||||
public function setId($id) {
|
public function setId($id) {
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
|
@ -98,7 +118,7 @@ class StorageConfig implements \JsonSerializable {
|
||||||
* "files" folder.
|
* "files" folder.
|
||||||
* The path will be normalized.
|
* The path will be normalized.
|
||||||
*
|
*
|
||||||
* @param string path
|
* @param string $mountPoint path
|
||||||
*/
|
*/
|
||||||
public function setMountPoint($mountPoint) {
|
public function setMountPoint($mountPoint) {
|
||||||
$this->mountPoint = \OC\Files\Filesystem::normalizePath($mountPoint);
|
$this->mountPoint = \OC\Files\Filesystem::normalizePath($mountPoint);
|
||||||
|
@ -134,7 +154,7 @@ class StorageConfig implements \JsonSerializable {
|
||||||
/**
|
/**
|
||||||
* Sets the external storage backend-specific options
|
* Sets the external storage backend-specific options
|
||||||
*
|
*
|
||||||
* @param array backend options
|
* @param array $backendOptions backend options
|
||||||
*/
|
*/
|
||||||
public function setBackendOptions($backendOptions) {
|
public function setBackendOptions($backendOptions) {
|
||||||
$this->backendOptions = $backendOptions;
|
$this->backendOptions = $backendOptions;
|
||||||
|
@ -152,7 +172,7 @@ class StorageConfig implements \JsonSerializable {
|
||||||
/**
|
/**
|
||||||
* Sets the mount priotity
|
* Sets the mount priotity
|
||||||
*
|
*
|
||||||
* @param int priority
|
* @param int $priority priority
|
||||||
*/
|
*/
|
||||||
public function setPriority($priority) {
|
public function setPriority($priority) {
|
||||||
$this->priority = $priority;
|
$this->priority = $priority;
|
||||||
|
@ -170,7 +190,7 @@ class StorageConfig implements \JsonSerializable {
|
||||||
/**
|
/**
|
||||||
* Sets the users for which to mount this storage
|
* Sets the users for which to mount this storage
|
||||||
*
|
*
|
||||||
* @param array applicable users
|
* @param array|null $applicableUsers applicable users
|
||||||
*/
|
*/
|
||||||
public function setApplicableUsers($applicableUsers) {
|
public function setApplicableUsers($applicableUsers) {
|
||||||
if (is_null($applicableUsers)) {
|
if (is_null($applicableUsers)) {
|
||||||
|
@ -191,7 +211,7 @@ class StorageConfig implements \JsonSerializable {
|
||||||
/**
|
/**
|
||||||
* Sets the groups for which to mount this storage
|
* Sets the groups for which to mount this storage
|
||||||
*
|
*
|
||||||
* @param array applicable groups
|
* @param array|null $applicableGroups applicable groups
|
||||||
*/
|
*/
|
||||||
public function setApplicableGroups($applicableGroups) {
|
public function setApplicableGroups($applicableGroups) {
|
||||||
if (is_null($applicableGroups)) {
|
if (is_null($applicableGroups)) {
|
||||||
|
@ -212,7 +232,7 @@ class StorageConfig implements \JsonSerializable {
|
||||||
/**
|
/**
|
||||||
* Sets the mount-specific options
|
* Sets the mount-specific options
|
||||||
*
|
*
|
||||||
* @param array applicable groups
|
* @param array $mountOptions applicable groups
|
||||||
*/
|
*/
|
||||||
public function setMountOptions($mountOptions) {
|
public function setMountOptions($mountOptions) {
|
||||||
if (is_null($mountOptions)) {
|
if (is_null($mountOptions)) {
|
||||||
|
|
|
@ -22,7 +22,6 @@ class GlobalStoragesService extends StoragesService {
|
||||||
/**
|
/**
|
||||||
* Write the storages to the configuration.
|
* Write the storages to the configuration.
|
||||||
*
|
*
|
||||||
* @param string $user user or null for global config
|
|
||||||
* @param array $storages map of storage id to storage config
|
* @param array $storages map of storage id to storage config
|
||||||
*/
|
*/
|
||||||
public function writeConfig($storages) {
|
public function writeConfig($storages) {
|
||||||
|
@ -121,8 +120,8 @@ class GlobalStoragesService extends StoragesService {
|
||||||
* accomodate for additions/deletions in applicableUsers
|
* accomodate for additions/deletions in applicableUsers
|
||||||
* and applicableGroups fields.
|
* and applicableGroups fields.
|
||||||
*
|
*
|
||||||
* @param StorageConfig $oldStorage old storage data
|
* @param StorageConfig $oldStorage old storage config
|
||||||
* @param StorageConfig $newStorage new storage data
|
* @param StorageConfig $newStorage new storage config
|
||||||
*/
|
*/
|
||||||
protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $newStorage) {
|
protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $newStorage) {
|
||||||
// if mount point changed, it's like a deletion + creation
|
// if mount point changed, it's like a deletion + creation
|
||||||
|
|
|
@ -36,9 +36,15 @@ abstract class StoragesService {
|
||||||
* @param string $mountType mount type
|
* @param string $mountType mount type
|
||||||
* @param string $applicable applicable user or group
|
* @param string $applicable applicable user or group
|
||||||
* @param array $storageOptions legacy storage options
|
* @param array $storageOptions legacy storage options
|
||||||
|
*
|
||||||
* @return StorageConfig populated storage config
|
* @return StorageConfig populated storage config
|
||||||
*/
|
*/
|
||||||
protected function populateStorageConfigWithLegacyOptions(&$storageConfig, $mountType, $applicable, $storageOptions) {
|
protected function populateStorageConfigWithLegacyOptions(
|
||||||
|
&$storageConfig,
|
||||||
|
$mountType,
|
||||||
|
$applicable,
|
||||||
|
$storageOptions
|
||||||
|
) {
|
||||||
$storageConfig->setBackendClass($storageOptions['class']);
|
$storageConfig->setBackendClass($storageOptions['class']);
|
||||||
$storageConfig->setBackendOptions($storageOptions['options']);
|
$storageConfig->setBackendOptions($storageOptions['options']);
|
||||||
if (isset($storageOptions['mountOptions'])) {
|
if (isset($storageOptions['mountOptions'])) {
|
||||||
|
@ -225,9 +231,10 @@ abstract class StoragesService {
|
||||||
/**
|
/**
|
||||||
* Get a storage with status
|
* Get a storage with status
|
||||||
*
|
*
|
||||||
* @param int $id
|
* @param int $id storage id
|
||||||
*
|
*
|
||||||
* @return StorageConfig
|
* @return StorageConfig
|
||||||
|
* @throws NotFoundException if the storage with the given id was not found
|
||||||
*/
|
*/
|
||||||
public function getStorage($id) {
|
public function getStorage($id) {
|
||||||
$allStorages = $this->readConfig();
|
$allStorages = $this->readConfig();
|
||||||
|
@ -319,7 +326,7 @@ abstract class StoragesService {
|
||||||
* @param StorageConfig $updatedStorage storage attributes
|
* @param StorageConfig $updatedStorage storage attributes
|
||||||
*
|
*
|
||||||
* @return StorageConfig storage config
|
* @return StorageConfig storage config
|
||||||
* @throws NotFoundException
|
* @throws NotFoundException if the given storage does not exist in the config
|
||||||
*/
|
*/
|
||||||
public function updateStorage(StorageConfig $updatedStorage) {
|
public function updateStorage(StorageConfig $updatedStorage) {
|
||||||
$allStorages = $this->readConfig();
|
$allStorages = $this->readConfig();
|
||||||
|
@ -344,7 +351,7 @@ abstract class StoragesService {
|
||||||
*
|
*
|
||||||
* @param int $id storage id
|
* @param int $id storage id
|
||||||
*
|
*
|
||||||
* @throws NotFoundException
|
* @throws NotFoundException if no storage was found with the given id
|
||||||
*/
|
*/
|
||||||
public function removeStorage($id) {
|
public function removeStorage($id) {
|
||||||
$allStorages = $this->readConfig();
|
$allStorages = $this->readConfig();
|
||||||
|
@ -376,7 +383,7 @@ abstract class StoragesService {
|
||||||
// but so did the mount.json. This horribly hack
|
// but so did the mount.json. This horribly hack
|
||||||
// will disappear once we move to DB tables to
|
// will disappear once we move to DB tables to
|
||||||
// store the config
|
// store the config
|
||||||
return max(array_keys($allStorages)) + 1;
|
return (max(array_keys($allStorages)) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,19 @@ use \OCA\Files_external\NotFoundException;
|
||||||
* (aka personal storages)
|
* (aka personal storages)
|
||||||
*/
|
*/
|
||||||
class UserStoragesService extends StoragesService {
|
class UserStoragesService extends StoragesService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* User session
|
||||||
|
*
|
||||||
* @var IUserSession
|
* @var IUserSession
|
||||||
*/
|
*/
|
||||||
private $userSession;
|
private $userSession;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a user storages service
|
||||||
|
*
|
||||||
|
* @param IUserSession $userSession user session
|
||||||
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
IUserSession $userSession
|
IUserSession $userSession
|
||||||
) {
|
) {
|
||||||
|
|
Loading…
Reference in a new issue