Skip to content

Commit

Permalink
chore: Use attributes for method annotation
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Oct 16, 2024
1 parent bd4118b commit 0c0913e
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions lib/Controller/DocumentAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
use OCA\Richdocuments\Helper;
use OCA\Richdocuments\TemplateManager;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\BruteForceProtection;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\JSONResponse;
use OCP\Files\Folder;
Expand All @@ -47,25 +50,18 @@
use Throwable;

class DocumentAPIController extends \OCP\AppFramework\OCSController {
private $rootFolder;
private $shareManager;
private $templateManager;
private $l10n;
private $logger;
private $lockManager;
private $session;
private $userId;

public function __construct(IRequest $request, IRootFolder $rootFolder, IManager $shareManager, TemplateManager $templateManager, IL10N $l10n, LoggerInterface $logger, ILockManager $lockManager, ISession $session, $userId) {
public function __construct(
IRequest $request,
private IRootFolder $rootFolder,
private IManager $shareManager,
private TemplateManager $templateManager,
private IL10N $l10n,
private LoggerInterface $logger,
private ILockManager $lockManager,
private ISession $session,
private ?string $userId
) {
parent::__construct(Application::APPNAME, $request);
$this->rootFolder = $rootFolder;
$this->shareManager = $shareManager;
$this->templateManager = $templateManager;
$this->l10n = $l10n;
$this->logger = $logger;
$this->lockManager = $lockManager;
$this->session = $session;
$this->userId = $userId;
}

/**
Expand All @@ -74,11 +70,10 @@ public function __construct(IRequest $request, IRootFolder $rootFolder, IManager
* As the server template API for file creation is not available there, we need a dedicated API
* in order to properly create files as public page visitors. This is being called in the new file
* actions in src/view/NewFileMenu.js
*
* @NoAdminRequired
* @PublicPage
* @BruteForceProtection(action=richdocumentsCreatePublic)
*/
#[NoAdminRequired]
#[PublicPage]
#[BruteForceProtection(action: 'richdocumentsCreatePublic')]
public function create(string $mimeType, string $fileName, string $directoryPath = '/', ?string $shareToken = null, ?int $templateId = null): JSONResponse {
try {
if ($shareToken !== null) {
Expand Down Expand Up @@ -172,7 +167,7 @@ public function create(string $mimeType, string $fileName, string $directoryPath
]);
}

#[Http\Attribute\NoAdminRequired]
#[NoAdminRequired]
public function openLocal(int $fileId): DataResponse {
try {
$files = $this->rootFolder->getUserFolder($this->userId)->getById($fileId);
Expand Down

0 comments on commit 0c0913e

Please sign in to comment.