Fix: Use event listener to load scripts on all pages
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<name>Minimal Profile</name>
|
||||
<summary>Hides profile fields to create a minimal user profile</summary>
|
||||
<description>Allows administrators to hide profile fields like pronouns, social links, etc.</description>
|
||||
<version>1.0.4</version>
|
||||
<version>1.0.5</version>
|
||||
<licence>AGPL</licence>
|
||||
<author>Your Name</author>
|
||||
<namespace>MinimalProfile</namespace>
|
||||
@@ -14,7 +14,4 @@
|
||||
<dependencies>
|
||||
<nextcloud min-version="33" max-version="33"/>
|
||||
</dependencies>
|
||||
<scripts>
|
||||
<script>minimalprofile</script>
|
||||
</scripts>
|
||||
</info>
|
||||
@@ -8,6 +8,9 @@ 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\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
|
||||
class Application extends App implements IBootstrap {
|
||||
|
||||
@@ -18,8 +21,23 @@ class Application extends App implements IBootstrap {
|
||||
}
|
||||
|
||||
public function register(IRegistrationContext $context): void {
|
||||
$context->registerEventListener(
|
||||
TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS,
|
||||
LoadScriptsListener::class
|
||||
);
|
||||
}
|
||||
|
||||
public function boot(IBootContext $context): void {
|
||||
}
|
||||
}
|
||||
|
||||
class LoadScriptsListener implements IEventListener {
|
||||
|
||||
public function handle(Event $event): void {
|
||||
if (!$event instanceof TemplateResponse) {
|
||||
return;
|
||||
}
|
||||
|
||||
$event->addScript('minimalprofile');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user