Skip to content

Commit

Permalink
fix api controller contstruction and routes
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Mar 26, 2021
1 parent f3f890f commit 4e35864
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 35 deletions.
20 changes: 10 additions & 10 deletions apps/files/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,44 +50,44 @@
],

[
'name' => 'API#getThumbnail',
'name' => 'Api#getThumbnail',
'url' => '/api/v1/thumbnail/{x}/{y}/{file}',
'verb' => 'GET',
'requirements' => ['file' => '.+']
],
[
'name' => 'API#updateFileTags',
'name' => 'Api#updateFileTags',
'url' => '/api/v1/files/{path}',
'verb' => 'POST',
'requirements' => ['path' => '.+'],
],
[
'name' => 'API#getRecentFiles',
'name' => 'Api#getRecentFiles',
'url' => '/api/v1/recent/',
'verb' => 'GET'
],
[
'name' => 'API#updateFileSorting',
'name' => 'Api#updateFileSorting',
'url' => '/api/v1/sorting',
'verb' => 'POST'
],
[
'name' => 'API#showHiddenFiles',
'name' => 'Api#showHiddenFiles',
'url' => '/api/v1/showhidden',
'verb' => 'POST'
],
[
'name' => 'API#cropImagePreviews',
'name' => 'Api#cropImagePreviews',
'url' => '/api/v1/cropimagepreviews',
'verb' => 'POST'
],
[
'name' => 'API#showGridView',
'name' => 'Api#showGridView',
'url' => '/api/v1/showgridview',
'verb' => 'POST'
],
[
'name' => 'API#getGridView',
'name' => 'Api#getGridView',
'url' => '/api/v1/showgridview',
'verb' => 'GET'
],
Expand All @@ -102,12 +102,12 @@
'verb' => 'GET',
],
[
'name' => 'API#toggleShowFolder',
'name' => 'Api#toggleShowFolder',
'url' => '/api/v1/toggleShowFolder/{key}',
'verb' => 'POST'
],
[
'name' => 'API#getNodeType',
'name' => 'Api#getNodeType',
'url' => '/api/v1/quickaccess/get/NodeType',
'verb' => 'GET',
],
Expand Down
19 changes: 0 additions & 19 deletions apps/files/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,6 @@ public function __construct(array $urlParams = []) {
}

public function register(IRegistrationContext $context): void {
/**
* Controllers
*/
$context->registerService('APIController', function (ContainerInterface $c) {
/** @var IServerContainer $server */
$server = $c->get(IServerContainer::class);

return new ApiController(
$c->get('AppName'),
$c->get(IRequest::class),
$c->get(IUserSession::class),
$c->get(TagService::class),
$c->get(IPreview::class),
$c->get(IShareManager::class),
$c->get(IConfig::class),
$server->getUserFolder()
);
});

/**
* Services
*/
Expand Down
13 changes: 7 additions & 6 deletions apps/files/lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
namespace OCA\Files\Controller;

use OC\Files\Node\Node;
use OCA\Files\AppInfo\Application;
use OCA\Files\Service\TagService;
use OCA\Files\SidebarNavigationManager;
use OCP\AppFramework\Controller;
Expand All @@ -48,6 +49,7 @@
use OCP\AppFramework\Http\Response;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\IConfig;
use OCP\IPreview;
Expand Down Expand Up @@ -78,33 +80,32 @@ class ApiController extends Controller {
private $navigationManager;

/**
* @param string $appName
* @param IRequest $request
* @param IUserSession $userSession
* @param TagService $tagService
* @param IPreview $previewManager
* @param IManager $shareManager
* @param IConfig $config
* @param Folder $userFolder
* @param IRootFolder $rootFolder
* @param SidebarNavigationManager $navigationManager
*/
public function __construct(
$appName,
IRequest $request,
IUserSession $userSession,
TagService $tagService,
IPreview $previewManager,
IManager $shareManager,
IConfig $config,
Folder $userFolder,
IRootFolder $rootFolder,
SidebarNavigationManager $navigationManager
) {
parent::__construct($appName, $request);
parent::__construct(Application::APP_ID, $request);
$this->userSession = $userSession;
$this->tagService = $tagService;
$this->previewManager = $previewManager;
$this->shareManager = $shareManager;
$this->config = $config;
$this->userFolder = $userFolder;
$this->userFolder = $rootFolder->getUserFolder($userSession->getUser()->getUID());
$this->navigationManager = $navigationManager;
}

Expand Down

0 comments on commit 4e35864

Please sign in to comment.