php: Move server code into new phpx package
This commit is contained in:
parent
4df5f6387c
commit
2e47626900
13 changed files with 134 additions and 86 deletions
|
|
@ -3,19 +3,22 @@ package php
|
|||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/php/phpserver"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/phpx"
|
||||
"github.com/alessio/shellescape"
|
||||
"github.com/tkw1536/goprogram/stream"
|
||||
)
|
||||
|
||||
type Server = phpserver.Server
|
||||
|
||||
// NewServer returns a new server that can execute code within this distillery.
|
||||
// When err == nil, the caller must call server.Close().
|
||||
//
|
||||
// See [PHPServer].
|
||||
func (php *PHP) NewServer() (*Server, error) {
|
||||
return phpserver.New(func(str stream.IOStream, script string) {
|
||||
php.Barrel.Shell(str, "-c", shellescape.QuoteCommand([]string{"drush", "php:eval", script}))
|
||||
})
|
||||
func (php *PHP) NewServer() *phpx.Server {
|
||||
return &phpx.Server{
|
||||
Executor: phpx.SpawnFunc(php.spawn),
|
||||
}
|
||||
}
|
||||
|
||||
func (php *PHP) spawn(str stream.IOStream, code string) error {
|
||||
_, err := php.Barrel.Shell(str, "-c", shellescape.QuoteCommand([]string{"drush", "php:eval", code}))
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue