Use event listener in register() for CSS

This commit is contained in:
2026-04-16 14:58:16 +02:00
parent ed41afe22e
commit 5527e50edd

View File

@@ -8,6 +8,7 @@ use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Util;
class Application extends App implements IBootstrap {
@@ -19,13 +20,17 @@ class Application extends App implements IBootstrap {
}
public function register(IRegistrationContext $context): void {
// Register event listener - this fires on EVERY page render after template is built
$context->registerEventListener(
TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS,
function() {
Util::addStyle('minimalprofile', 'minimalprofile');
}
);
file_put_contents('/tmp/minimalprofile.log', date('Y-m-d H:i:s') . ' register, event registered' . "\n", FILE_APPEND);
}
public function boot(IBootContext $context): void {
// Load CSS from our css/ folder using standard Util::addStyle
// This loads css/minimalprofile.css
Util::addStyle('minimalprofile', 'minimalprofile');
file_put_contents('/tmp/minimalprofile.log', date('Y-m-d H:i:s') . ' boot, loaded style' . "\n", FILE_APPEND);
}
}