retro/lib/Controller/PageController.php
Michel Roux c8d5e899f7
Some checks failed
retro / xml (push) Successful in 27s
retro / php (push) Failing after 1m15s
retro / nodejs (push) Failing after 1m40s
retro / release (push) Has been skipped
feat: 🌱 include script ok
2025-01-03 22:50:29 +01:00

49 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace OCA\Retro\Controller;
use OCA\Retro\AppInfo\Application;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Files\IRootFolder;
use OCP\IRequest;
use OCP\IUserSession;
use OCP\Util;
class PageController extends Controller
{
public function __construct(
IRequest $request,
private readonly IRootFolder $rootFolder,
private readonly IUserSession $userSession
) {
parent::__construct(Application::APP_ID, $request);
}
#[NoCSRFRequired]
#[NoAdminRequired]
#[FrontpageRoute(verb: 'GET', url: '/{path}', requirements: ['path' => '.+'])]
public function run(string $path): TemplateResponse {
$user = $this->userSession->getUser();
if (!$user) {
throw new \Exception('User not logged in');
}
$folder = $this->rootFolder->getUserFolder($user->getUID());
$folder->get($path);
Util::addScript(Application::APP_ID, Application::APP_ID.'-main');
return new TemplateResponse(
Application::APP_ID,
'index',
);
}
}