Simplify: direct IConfig query, green border
This commit is contained in:
@@ -4,11 +4,11 @@ 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;
|
||||
use OCP\IConfig;
|
||||
use OCP\Util;
|
||||
|
||||
class Application extends App implements IBootstrap {
|
||||
@@ -20,22 +20,30 @@ class Application extends App implements IBootstrap {
|
||||
}
|
||||
|
||||
public function register(IRegistrationContext $context): void {
|
||||
$context->registerService(Config::class, function($c) {
|
||||
return new Config($c->get(\OCP\IConfig::class));
|
||||
});
|
||||
}
|
||||
|
||||
public function boot(IBootContext $context): void {
|
||||
$container = $context->getAppContainer();
|
||||
$config = $container->query(Config::class);
|
||||
$hidden = $config->getHiddenFields();
|
||||
$config = $container->query(IConfig::class);
|
||||
|
||||
$value = $config->getAppValue('minimalprofile', 'hidden_fields', '');
|
||||
$hidden = ($value !== '') ? json_decode($value, true) ?? [] : [];
|
||||
|
||||
$css = '';
|
||||
if (!empty($hidden)) {
|
||||
$css = $config->generateCss($hidden);
|
||||
$selectors = [
|
||||
'pronouns' => '#account-property-pronouns',
|
||||
'role' => '#account-property-role',
|
||||
'headline' => '#account-property-headline',
|
||||
];
|
||||
foreach ($hidden as $field) {
|
||||
if (isset($selectors[$field])) {
|
||||
$css .= $selectors[$field] . ' { display: none !important; }' . "\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Debug - always show something
|
||||
$css = 'body { border: 20px solid blue !important; }';
|
||||
// Debug
|
||||
$css = 'body { border: 30px solid green !important; }';
|
||||
}
|
||||
|
||||
if ($css) {
|
||||
|
||||
Reference in New Issue
Block a user