- Added basic exception remodeling, seaking original template sources.
This commit is contained in:
1 parent
10632e9f67
commit
1334278e37
7 files changed
+232
-57
No files matched your search
@@ -5,65 +5,85 @@ namespace %NAMESPACE%;
|
||||
%USE%
|
||||
|
||||
# %PATHNAME%
|
||||
class %CLASSNAME% %EXTENDS% {
|
||||
public array $blockList = [];
|
||||
|
||||
public array $sectionList = [];
|
||||
if (! class_exists("%NAMESPACE%\%CLASSNAME%", false) ) {
|
||||
|
||||
public array $variableList = [];
|
||||
class %CLASSNAME% %EXTENDS% {
|
||||
public array $blockList = [];
|
||||
|
||||
public ?object $thisProxy = null;
|
||||
public array $sectionList = [];
|
||||
|
||||
public \Picea\Picea $picea;
|
||||
public array $variableList = [];
|
||||
|
||||
public static $context;
|
||||
|
||||
public function __construct(\Picea\Picea $picea, array $variablesList = [], ?object $thisProxy = null) {
|
||||
$this->picea = $picea;
|
||||
$this->variableList = $variablesList;
|
||||
$this->thisProxy = $thisProxy;
|
||||
$this->exportFunctions();
|
||||
|
||||
static::$context = $picea->context;
|
||||
}
|
||||
public ?object $thisProxy = null;
|
||||
|
||||
public function output(array $variablesList = []) : void
|
||||
{
|
||||
( function($___class__template, $___global_variables, $___variables, $picea) {
|
||||
extract($___global_variables);
|
||||
extract($___variables, \EXTR_OVERWRITE);
|
||||
?>%CONTENT%<?php
|
||||
} )->call($this->thisProxy ?? new class(){}, $this, $this->variableList, $variablesList, $this->picea);
|
||||
%PARENT_OUTPUT%
|
||||
}
|
||||
public \Picea\Picea $picea;
|
||||
|
||||
public function renderSection($name) : void
|
||||
{
|
||||
foreach([ 'prepend', 'default', 'append' ] as $item) {
|
||||
usort($this->sectionList[$name][$item], fn($a, $b) => $a['order'] <=> $b['order']);
|
||||
public static $context;
|
||||
|
||||
foreach($this->sectionList[$name][$item] as $section) {
|
||||
$section['callback']();
|
||||
public function __construct(\Picea\Picea $picea, array $variablesList = [], ?object $thisProxy = null) {
|
||||
$this->picea = $picea;
|
||||
$this->variableList = $variablesList;
|
||||
$this->thisProxy = $thisProxy;
|
||||
$this->exportFunctions();
|
||||
|
||||
if ( $item === 'default' ) {
|
||||
break 1;
|
||||
static::$context = $picea->context;
|
||||
}
|
||||
|
||||
public function output(array $variablesList = []) : void
|
||||
{
|
||||
( function($___class__template, $___global_variables, $___variables, $picea) {
|
||||
extract($___global_variables);
|
||||
extract($___variables, \EXTR_OVERWRITE);
|
||||
?>%CONTENT%<?php
|
||||
} )->call($this->thisProxy ?? new class(){}, $this, $this->variableList, $variablesList, $this->picea);
|
||||
%PARENT_OUTPUT%
|
||||
}
|
||||
|
||||
public function renderSection($name) : void
|
||||
{
|
||||
foreach([ 'prepend', 'default', 'append' ] as $item) {
|
||||
usort($this->sectionList[$name][$item], fn($a, $b) => $a['order'] <=> $b['order']);
|
||||
|
||||
foreach($this->sectionList[$name][$item] as $section) {
|
||||
$section['callback']();
|
||||
|
||||
if ( $item === 'default' ) {
|
||||
break 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function exportFunctions() : void
|
||||
{
|
||||
static $caching = [];
|
||||
%FUNCTIONS%
|
||||
|
||||
public function exportFunctions() : void
|
||||
{
|
||||
static $caching = [];
|
||||
%FUNCTIONS%
|
||||
}
|
||||
|
||||
public function getSourceLineFromException(\Throwable $ex) : ? int
|
||||
{
|
||||
$sourceFile = file_get_contents("%TEMPLATE%");
|
||||
|
||||
if ( $sourceFile ) {
|
||||
foreach(explode(PHP_EOL, $sourceFile) as $line => $content) {
|
||||
if ( strpos($content, str_replace('$', '%', '$CONTENT$')) !== false ) {
|
||||
return $ex->getLine() - $line;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function __invoke(array $variablesList = []) : string
|
||||
{
|
||||
ob_start();
|
||||
$this->output($variablesList);
|
||||
return ob_get_clean();
|
||||
}
|
||||
}
|
||||
|
||||
public function __invoke(array $variablesList = []) : string
|
||||
{
|
||||
ob_start();
|
||||
$this->output($variablesList);
|
||||
return ob_get_clean();
|
||||
}
|
||||
}
|
||||
|
||||
return [ 'classname' => "%CLASSNAME%", 'namespace' => "%NAMESPACE%", 'extends' => "%EXTENDS_TEMPLATE%" ];
|
||||
return [ 'classname' => "%CLASSNAME%", 'namespace' => "%NAMESPACE%", 'extends' => "%EXTENDS_TEMPLATE%", 'view' => "%FULLPATH%" ];
|
||||
Reference in new issue
Block a user