wisski-cloud-distillery/internal/wisski/ingredient/php/extras/theme.go

41 lines
893 B
Go

package extras
import (
"context"
"github.com/FAU-CDI/wisski-distillery/internal/phpx"
"github.com/FAU-CDI/wisski-distillery/internal/status"
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/php"
_ "embed"
)
// Prefixes implements reading and writing prefix
type Theme struct {
ingredient.Base
Dependencies struct {
PHP *php.PHP
}
}
//go:embed theme.php
var themePHP string
// Get returns the currently active theme
func (t *Theme) Get(ctx context.Context, server *phpx.Server) (theme string, err error) {
err = t.Dependencies.PHP.ExecScript(
ctx, server, &theme, themePHP,
"get_active_theme",
)
return
}
func (t *Theme) Fetch(flags ingredient.FetcherFlags, info *status.WissKI) (err error) {
if flags.Quick {
return
}
info.Theme, _ = t.Get(flags.Context, flags.Server)
return
}