Move WissKI Parts to new ingredients system
This commit is contained in:
parent
b5b1ce2340
commit
42b8cbd865
83 changed files with 1016 additions and 646 deletions
44
internal/wisski/ingredient/php/extras/pathbuilder.go
Normal file
44
internal/wisski/ingredient/php/extras/pathbuilder.go
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
package extras
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/php"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
type Pathbuilder struct {
|
||||
ingredient.Base
|
||||
|
||||
PHP *php.PHP
|
||||
}
|
||||
|
||||
//go:embed pathbuilder.php
|
||||
var pathbuilderPHP string
|
||||
|
||||
// All returns the ids of all pathbuilders in consistent order.
|
||||
//
|
||||
// server is the server to fetch the pathbuilders from, any may be nil.
|
||||
func (pathbuilder *Pathbuilder) All(server *php.Server) (ids []string, err error) {
|
||||
err = pathbuilder.PHP.ExecScript(server, &ids, pathbuilderPHP, "all_list")
|
||||
slices.Sort(ids)
|
||||
return
|
||||
}
|
||||
|
||||
// Get returns a single pathbuilder as xml.
|
||||
// If it does not exist, it returns the empty string and nil error.
|
||||
//
|
||||
// server is the server to fetch the pathbuilders from, any may be nil.
|
||||
func (pathbuilder *Pathbuilder) Get(server *php.Server, id string) (xml string, err error) {
|
||||
err = pathbuilder.PHP.ExecScript(server, &xml, pathbuilderPHP, "one_xml", id)
|
||||
return
|
||||
}
|
||||
|
||||
// GetAll returns all pathbuilders serialized as xml
|
||||
//
|
||||
// server is the server to fetch the pathbuilders from, any may be nil.
|
||||
func (pathbuilder *Pathbuilder) GetAll(server *php.Server) (pathbuilders map[string]string, err error) {
|
||||
err = pathbuilder.PHP.ExecScript(server, &pathbuilders, pathbuilderPHP, "all_xml")
|
||||
return
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue