Use event listener in register() for CSS
This commit is contained in:
@@ -8,6 +8,7 @@ use OCP\AppFramework\App;
|
|||||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||||
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
||||||
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
use OCP\Util;
|
use OCP\Util;
|
||||||
|
|
||||||
class Application extends App implements IBootstrap {
|
class Application extends App implements IBootstrap {
|
||||||
@@ -19,13 +20,17 @@ class Application extends App implements IBootstrap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function register(IRegistrationContext $context): void {
|
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 {
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user