This commit adds and passes context around to (almost) every function. This allows cancelling (almost) every function call globally.
28 lines
749 B
Go
28 lines
749 B
Go
package extras
|
|
|
|
import (
|
|
"context"
|
|
_ "embed"
|
|
|
|
"github.com/FAU-CDI/wisski-distillery/internal/phpx"
|
|
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
|
|
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/php"
|
|
)
|
|
|
|
type Settings struct {
|
|
ingredient.Base
|
|
|
|
PHP *php.PHP
|
|
}
|
|
|
|
//go:embed settings.php
|
|
var settingsPHP string
|
|
|
|
func (settings *Settings) Get(ctx context.Context, server *phpx.Server, key string) (value any, err error) {
|
|
err = settings.PHP.ExecScript(ctx, server, &value, settingsPHP, "get_setting", key)
|
|
return
|
|
}
|
|
|
|
func (settings *Settings) Set(ctx context.Context, server *phpx.Server, key string, value any) error {
|
|
return settings.PHP.ExecScript(ctx, server, nil, settingsPHP, "set_setting", key, value)
|
|
}
|