Allow apps to register resource providers

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2019-01-24 11:43:18 +01:00
parent 88aa3de784
commit d85e3e3a6d
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
3 changed files with 24 additions and 4 deletions

View File

@ -27,9 +27,11 @@
namespace OCA\Files\AppInfo;
use OCA\Files\Activity\Helper;
use OCA\Files\Collaboration\Resources\ResourceProvider;
use OCA\Files\Controller\ApiController;
use OCP\AppFramework\App;
use \OCA\Files\Service\TagService;
use OCP\Collaboration\Resources\IManager;
use \OCP\IContainer;
use OCA\Files\Controller\ViewController;
use OCA\Files\Capabilities;
@ -99,5 +101,12 @@ class Application extends App {
* Register capabilities
*/
$container->registerCapability(Capabilities::class);
/**
* Register Collaboration ResourceProvider
*/
/** @var IManager $resourceManager */
$resourceManager = $container->query(IManager::class);
$resourceManager->registerResourceProvider($container->query(ResourceProvider::class));
}
}

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace OC\Collaboration\Resources;
use OCA\Files\Collaboration\Resources\ResourceProvider;
use OCP\Collaboration\Resources\CollectionException;
use OCP\Collaboration\Resources\ICollection;
use OCP\Collaboration\Resources\IManager;
@ -39,6 +38,9 @@ class Manager implements IManager {
/** @var IDBConnection */
protected $connection;
/** @var IProvider[] */
protected $providers = [];
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
}
@ -96,9 +98,7 @@ class Manager implements IManager {
* @since 15.0.0
*/
public function getProviders(): array {
return [
\OC::$server->query(ResourceProvider::class) // FIXME
];
return $this->providers;
}
/**
@ -155,4 +155,11 @@ class Manager implements IManager {
return false;
}
/**
* @param IProvider $provider
*/
public function registerResourceProvider(IProvider $provider): void {
$this->providers[] = $provider;
}
}

View File

@ -50,4 +50,8 @@ interface IManager extends IProvider {
*/
public function getResource(string $type, string $id): IResource;
/**
* @param IProvider $provider
*/
public function registerResourceProvider(IProvider $provider): void;
}