Files
nextcloud_minimalprofile/lib/AppInfo/Application.php

49 lines
1.2 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace OCA\MinimalProfile\AppInfo;
use OCA\MinimalProfile\Service\Config;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
2026-04-16 14:34:08 +02:00
use OCP\AppFramework\Http\TemplateResponse;
use OCP\EventDispatcher\Event;
use OCP\Util;
class Application extends App implements IBootstrap {
public const APP_ID = 'minimalprofile';
public function __construct(array $urlParams = []) {
parent::__construct(self::APP_ID, $urlParams);
}
public function register(IRegistrationContext $context): void {
$context->registerService(Config::class, function($c) {
return new Config($c->get(\OCP\IConfig::class));
});
2026-04-16 14:34:08 +02:00
$context->registerEventListener(
TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS,
function(Event $event) {
if (!($event instanceof TemplateResponse)) {
return;
}
$container = $event->getAppContainer();
$config = $container->query(Config::class);
$hidden = $config->getHiddenFields();
if (!empty($hidden)) {
$css = $config->generateCss($hidden);
Util::addInlineStyle($css);
2026-04-16 14:34:08 +02:00
}
}
);
}
public function boot(IBootContext $context): void {
}
}