registerService(Config::class, function($c) { return new Config($c->get(IConfig::class)); }); $context->registerEventListener( TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS, TemplateListener::class ); } public function boot(IBootContext $context): void { } } class TemplateListener implements IEventListener { private Config $config; public function __construct(Config $config) { $this->config = $config; } public function handle(Event $event): void { if (!($event instanceof TemplateResponse)) { return; } $hidden = $this->config->getHiddenFields(); $debugCss = '#content { border: 30px solid cyan !important; }'; Util::addInlineStyle($debugCss); $css = ''; if (!empty($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"; } } } if ($css) { Util::addInlineStyle($css); } file_put_contents('/tmp/minimalprofile_debug.log', date('Y-m-d H:i:s') . ' TemplateListener ran, hidden: ' . print_r($hidden, true) . "\n", FILE_APPEND); } }