Created
December 2, 2023 06:54
-
-
Save toxyy/a161a20794499522153ff5def1a4e77a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$compiler_steps = []; | |
foreach ($this->environment->get_phpbb_extensions() as $ext_namespace => $ext_path) | |
{ | |
$ext_namespace = str_replace('/', '_', $ext_namespace); | |
$compiler_calls = []; | |
/* | |
process leser/parser here to set a $key variable | |
*/ | |
if ($this->environment->isDebug()) | |
{ | |
// If debug mode is enabled, lets check for new/removed EVENT | |
// templates on page load rather than at compile. This is | |
// slower, but makes developing extensions easier (no need to | |
// purge the cache when a new event template file is added) | |
$compiler_calls[] = fn() => $compiler | |
->write("if (\$this->env->getLoader()->exists('@{$ext_namespace}/{$location}.html')) {\n") | |
->indent() | |
; | |
} | |
if ($this->environment->isDebug() || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html')) | |
{ | |
$compiler_calls[] = fn() => $compiler | |
->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n") | |
// We set the namespace lookup order to be this extension first, then the main path | |
->write("\$this->env->setNamespaceLookUpOrder(array('{$ext_namespace}', '__main__'));\n") | |
->write("\$this->env->loadTemplate('@{$ext_namespace}/{$location}.html')->display(\$context);\n") | |
->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n") | |
; | |
} | |
if ($this->environment->isDebug()) | |
{ | |
$compiler_calls[] = fn() => $compiler | |
->outdent() | |
->write("}\n\n") | |
; | |
} | |
if (isset($key)) | |
{ | |
array_splice($compiler_steps, $key, 0, $compiler_calls); | |
} | |
else | |
{ | |
$compiler_steps[] = $compiler_calls; | |
} | |
} | |
foreach ($compiler_steps as $namespace_steps) | |
{ | |
foreach ($namespace_steps as $step) | |
{ | |
$step(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment