- Work on Language Handler and extension.
- Added an URL extension which allows routes and URLs. - Fixed some bug within ClassTemplate
This commit is contained in:
1 parent
a64989af9f
commit
ddc3ae704a
10 files changed
+267
-82
No files matched your search
@@ -22,6 +22,8 @@ abstract class Context {
|
||||
|
||||
public array $useStack = [];
|
||||
|
||||
public array $functionStack = [];
|
||||
|
||||
public array $hooks = [];
|
||||
|
||||
public Compiler $compiler;
|
||||
@@ -45,13 +47,38 @@ abstract class Context {
|
||||
|
||||
public function renderUses() : string
|
||||
{
|
||||
return implode(",", $context->useStack ?? []);
|
||||
return implode(",", $this->useStack ?? []);
|
||||
}
|
||||
|
||||
#public function variables(array $variables) : void
|
||||
#{
|
||||
# $this->variables = $variables;
|
||||
#}
|
||||
public function renderFunctions() : string
|
||||
{
|
||||
$cls = $this->compiledClassPath();
|
||||
$ns = $this->namespace ? "\\{$this->namespace}\\" : "";
|
||||
|
||||
foreach($this->functionStack as $name => $function) {
|
||||
$list[] = <<<FUNC
|
||||
if ( false === ( ( \$caching['$ns$name'] ?? false) || function_exists( '$ns$name' ) ) ) {
|
||||
\$caching['$ns$name'] = true;
|
||||
|
||||
function $name(...\$arguments) {
|
||||
return $cls::\$context->functionStack['$name'](...\$arguments);
|
||||
}
|
||||
}
|
||||
FUNC;
|
||||
}
|
||||
|
||||
return implode(PHP_EOL, $list);
|
||||
}
|
||||
|
||||
public function exportFunctions() : void
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function pushFunction($name, Callable $callable) : void
|
||||
{
|
||||
$this->functionStack[$name] = $callable;
|
||||
}
|
||||
|
||||
public function compiledClassPath() : string
|
||||
{
|
||||
@@ -61,4 +88,9 @@ abstract class Context {
|
||||
|
||||
return $this->className;
|
||||
}
|
||||
|
||||
public function cacheFilename() : string
|
||||
{
|
||||
return strtolower(str_replace("\\", DIRECTORY_SEPARATOR, $this->namespace)) . ".context";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user