requirePost(); $id = $ctx->post('id'); $ctx->requireCsrf('toggle:' . $id); $rule = $ctx->rules->find($ctx->daUser->username(), $id); if ($rule === null) { throw new RuntimeException($ctx->t('Rule not found')); } $next = ['enabled' => empty($rule['enabled'])]; enforce_rule_backend_constraints($ctx, $id, $next); $ctx->rules->update($ctx->daUser->username(), $id, $next); $ctx->syncActiveBackend(); Http::redirect($ctx->url('index.html', ['status' => 'toggled'])); } catch (Throwable $e) { PluginLogger::exception($e, 'TOGGLE'); throw $e; } };