39 lines
725 B
PHP
39 lines
725 B
PHP
|
<?php
|
||
|
|
||
|
namespace VfxApply\Plugin\Executor;
|
||
|
|
||
|
use VfxApply\Plugin;
|
||
|
use VfxApply\Input;
|
||
|
use VfxApply\Output;
|
||
|
use VfxApply\Preset;
|
||
|
|
||
|
class Helper
|
||
|
{
|
||
|
protected $body;
|
||
|
|
||
|
protected $script;
|
||
|
|
||
|
public function __construct($body)
|
||
|
{
|
||
|
$this->body = $body;
|
||
|
}
|
||
|
|
||
|
public function setScript(Script $script)
|
||
|
{
|
||
|
$this->script = $script;
|
||
|
}
|
||
|
|
||
|
public function call(array $env)
|
||
|
{
|
||
|
$body = "<?php ".preg_replace_callback('/(\{\{\%([a-z]+)\}\})/', function ($m) use ($env) {
|
||
|
return $env[$m[2]];
|
||
|
}, $this->body);
|
||
|
|
||
|
$tmpname = tempnam(null, "vfxhelper");
|
||
|
file_put_contents($tmpname, $body);
|
||
|
passthru("php {$tmpname}");
|
||
|
unlink($tmpname);
|
||
|
}
|
||
|
}
|
||
|
|