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')); } $ctx->rules->update($ctx->daUser->username(), $id, ['enabled' => empty($rule['enabled'])]); $ctx->syncActiveBackend(); Http::redirect($ctx->url('index.html', ['status' => 'toggled'])); };