mirror of
https://gitnet.fr/deblan/side_menu.git
synced 2025-12-18 05:10:50 +01:00
refactor(controller): usage of attributes instead of annotations
This commit is contained in:
parent
37b9beb8f7
commit
b03a7f7bad
8 changed files with 45 additions and 69 deletions
|
|
@ -55,7 +55,7 @@ In case of downtime, you can download **Custom Menu** from [here](https://kim.de
|
|||
<screenshot>https://gitnet.fr/deblan/side_menu/raw/branch/master/screenshots/nc25_default_menu.png</screenshot>
|
||||
<dependencies>
|
||||
<nextcloud min-version="30" max-version="30"/>
|
||||
<php min-version="8.0"/>
|
||||
<php min-version="8.1"/>
|
||||
</dependencies>
|
||||
<settings>
|
||||
<admin>OCA\SideMenu\Settings\Admin</admin>
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
return [
|
||||
'routes' => [
|
||||
['name' => 'App#index', 'url' => '/', 'verb' => 'GET'],
|
||||
['name' => 'Css#stylesheet', 'url' => '/css/stylesheet', 'verb' => 'GET'],
|
||||
['name' => 'Js#script', 'url' => '/js/script', 'verb' => 'GET'],
|
||||
['name' => 'Js#config', 'url' => '/js/config', 'verb' => 'GET'],
|
||||
['name' => 'Nav#items', 'url' => '/nav/items', 'verb' => 'GET'],
|
||||
['name' => 'PersonalSetting#valueSet', 'url' => '/personalSetting/valueSet', 'verb' => 'POST'],
|
||||
['name' => 'AdminSetting#removeCache', 'url' => '/admin/cache/remove', 'verb' => 'GET'],
|
||||
['name' => 'AdminSetting#exportConfiguration', 'url' => '/admin/config/export', 'verb' => 'GET'],
|
||||
],
|
||||
];
|
||||
|
|
@ -20,11 +20,13 @@ namespace OCA\SideMenu\Controller;
|
|||
|
||||
use OCA\SideMenu\AppInfo\Application;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
||||
use OCP\AppFramework\Http\DataDownloadResponse;
|
||||
use OCP\AppFramework\Http\RedirectResponse;
|
||||
use OCP\IConfig;
|
||||
use OCP\IRequest;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
|
||||
|
||||
class AdminSettingController extends Controller
|
||||
{
|
||||
|
|
@ -37,9 +39,8 @@ class AdminSettingController extends Controller
|
|||
parent::__construct($appName, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
#[NoCSRFRequired]
|
||||
#[FrontpageRoute(verb: 'GET', url: '/admin/cache/remove')]
|
||||
public function removeCache(): RedirectResponse
|
||||
{
|
||||
$this->config->setAppValue(Application::APP_ID, 'cache-categories', '[]');
|
||||
|
|
@ -49,9 +50,8 @@ class AdminSettingController extends Controller
|
|||
]).'#more');
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
#[NoCSRFRequired]
|
||||
#[FrontpageRoute(verb: 'GET', url: '/admin/config/export')]
|
||||
public function exportConfiguration(): DataDownloadResponse
|
||||
{
|
||||
$keys = $this->config->getAppKeys(Application::APP_ID);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ use OCP\AppFramework\Http\RedirectResponse;
|
|||
use OCP\IRequest;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IUserSession;
|
||||
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
||||
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
||||
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
|
||||
|
||||
class AppController extends Controller
|
||||
{
|
||||
|
|
@ -39,10 +42,9 @@ class AppController extends Controller
|
|||
parent::__construct($appName, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
#[NoCSRFRequired]
|
||||
#[NoAdminRequired]
|
||||
#[FrontpageRoute(verb: 'GET', url: '/')]
|
||||
public function index(): RedirectResponse
|
||||
{
|
||||
$user = OC::$server[IUserSession::class]->getUser();
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ use OCP\AppFramework\Http\Response;
|
|||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\IRequest;
|
||||
use OCP\IUserSession;
|
||||
use OCP\AppFramework\Http\Attribute\PublicPage;
|
||||
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
|
||||
|
||||
class CssController extends Controller
|
||||
{
|
||||
|
|
@ -46,11 +48,10 @@ class CssController extends Controller
|
|||
$this->user = OC::$server[IUserSession::class]->getUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
*/
|
||||
#[NoCSRFRequired]
|
||||
#[NoAdminRequired]
|
||||
#[PublicPage]
|
||||
#[FrontpageRoute(verb: 'GET', url: '/css/stylesheet')]
|
||||
public function stylesheet(): TemplateResponse
|
||||
{
|
||||
$response = new TemplateResponse(Application::APP_ID, 'css/stylesheet', $this->getConfig(), 'blank');
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@ use OCP\AppFramework\Http\TemplateResponse;
|
|||
use OCP\IRequest;
|
||||
use OCP\IUserSession;
|
||||
use OCP\L10N\IFactory;
|
||||
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
||||
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
||||
use OCP\AppFramework\Http\Attribute\PublicPage;
|
||||
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
|
||||
|
||||
class JsController extends Controller
|
||||
{
|
||||
|
|
@ -50,11 +54,10 @@ class JsController extends Controller
|
|||
$this->l10nFactory = $l10nFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
*/
|
||||
#[NoCSRFRequired]
|
||||
#[NoAdminRequired]
|
||||
#[PublicPage]
|
||||
#[FrontpageRoute(verb: 'GET', url: '/js/script')]
|
||||
public function script(): TemplateResponse
|
||||
{
|
||||
$response = new TemplateResponse(Application::APP_ID, 'js/script', $this->getConfig(), 'blank');
|
||||
|
|
@ -63,11 +66,10 @@ class JsController extends Controller
|
|||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
*/
|
||||
#[NoCSRFRequired]
|
||||
#[NoAdminRequired]
|
||||
#[PublicPage]
|
||||
#[FrontpageRoute(verb: 'GET', url: '/js/config')]
|
||||
public function config(): JSONResponse
|
||||
{
|
||||
return new JSONResponse($this->getConfig());
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@ use OCP\AppFramework\Http\JSONResponse;
|
|||
use OCP\IRequest;
|
||||
use OCP\IUserSession;
|
||||
use OCP\L10N\IFactory;
|
||||
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
||||
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
||||
use OCP\AppFramework\Http\Attribute\PublicPage;
|
||||
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
|
||||
|
||||
class NavController extends Controller
|
||||
{
|
||||
|
|
@ -43,11 +47,10 @@ class NavController extends Controller
|
|||
parent::__construct($appName, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
*/
|
||||
#[NoCSRFRequired]
|
||||
#[NoAdminRequired]
|
||||
#[PublicPage]
|
||||
#[FrontpageRoute(verb: 'GET', url: '/nav/items')]
|
||||
public function items(): JSONResponse
|
||||
{
|
||||
$user = OC::$server[IUserSession::class]->getUser();
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ use OCP\AppFramework\Controller;
|
|||
use OCP\IConfig;
|
||||
use OCP\IRequest;
|
||||
use OCP\IUserSession;
|
||||
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
||||
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
||||
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
|
||||
|
||||
class PersonalSettingController extends Controller
|
||||
{
|
||||
|
|
@ -37,13 +40,9 @@ class PersonalSettingController extends Controller
|
|||
parent::__construct($appName, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param mixed $name
|
||||
* @param mixed $value
|
||||
*/
|
||||
#[NoCSRFRequired]
|
||||
#[NoAdminRequired]
|
||||
#[FrontpageRoute(verb: 'POST', url: '/personalSetting/valueSet')]
|
||||
public function valueSet($name, $value): array
|
||||
{
|
||||
$doSave = false;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue