LegacyViewConverter
in package
Converts a legacy ZubZet view/layout (the "return type" syntax) into a Katana .blade.php document, as part of the 1.3.0 upgrade.
Views become template-inheritance children. The old "body" closure turns into @section("content"), an optional "head" closure into @section("head"), and the file @extends the layout picked at render time:
Tags
Table of Contents
- convertFile() : string
- Convert any legacy view or layout. Returns the .blade.php document.
- convertLayout() : string
- A legacy layout -> the parent template with @yield placeholders.
- convertView() : string
- A legacy view -> an @extends child with head/content sections.
- extractSections() : array<string|int, mixed>
- isLayout() : bool
- True when the source is a legacy layout (returns a "layout" closure).
- isLegacyView() : bool
- True when the source looks like a legacy return[...] view/layout at all.
- neutralize() : string
- Escape literal Blade markers so Katana emits them verbatim, but only in template HTML (T_INLINE_HTML). Markers inside raw PHP are already safe.
- dedent() : string
- Remove the common leading indentation (the wrapper closure's indent) so a dedented document sits at column 0. A first line left inline with the opening ?> tag has a smaller indent than the block and is treated as an outlier so it does not shrink the common indent to remove.
- describe() : string
- detokenizeTemplate() : string
- Reconstruct template text from closure-body tokens, stripping the wrapping tags.
- escapeMarkers() : string
- essentialsTags() : string
- Replace the framework's layout-essentials closure calls with the Blade components the framework provides for them (resolved via a shared anonymous-component path), so a layout carries no raw essentials PHP.
- extractClosure() : array<string|int, mixed>
- section() : string
- Section body: keep its indentation (it nests under @section), trim blank edges.
- yieldCall() : string
- Replace a call to a layout closure param (`<?= $body($opt) ?>`, the "echo" form or a bare statement form) with the matching @yield.
Methods
convertFile()
Convert any legacy view or layout. Returns the .blade.php document.
public
static convertFile(string $source) : string
Parameters
- $source : string
Tags
Return values
string —convertLayout()
A legacy layout -> the parent template with @yield placeholders.
public
static convertLayout(string $source) : string
Parameters
- $source : string
Return values
string —convertView()
A legacy view -> an @extends child with head/content sections.
public
static convertView(string $source) : string
Parameters
- $source : string
Return values
string —extractSections()
public
static extractSections(string $source) : array<string|int, mixed>
Parameters
- $source : string
Return values
array<string|int, mixed> —isLayout()
True when the source is a legacy layout (returns a "layout" closure).
public
static isLayout(string $source) : bool
Parameters
- $source : string
Return values
bool —isLegacyView()
True when the source looks like a legacy return[...] view/layout at all.
public
static isLegacyView(string $source) : bool
Parameters
- $source : string
Return values
bool —neutralize()
Escape literal Blade markers so Katana emits them verbatim, but only in template HTML (T_INLINE_HTML). Markers inside raw PHP are already safe.
public
static neutralize(string $tpl) : string
{{-- .. --}} -> wrapped in @verbatim (the @{{-- escape does not work because comments are stripped before echo-escaping) {!! .. !!} -> @{!! .. !!} {{ .. }} -> @{{ .. }}
Parameters
- $tpl : string
Return values
string —dedent()
Remove the common leading indentation (the wrapper closure's indent) so a dedented document sits at column 0. A first line left inline with the opening ?> tag has a smaller indent than the block and is treated as an outlier so it does not shrink the common indent to remove.
private
static dedent(string $content) : string
Parameters
- $content : string
Return values
string —describe()
private
static describe(mixed $t) : string
Parameters
- $t : mixed
Return values
string —detokenizeTemplate()
Reconstruct template text from closure-body tokens, stripping the wrapping tags.
private
static detokenizeTemplate(array<string|int, mixed> $bodyTokens) : string
Parameters
- $bodyTokens : array<string|int, mixed>
Return values
string —escapeMarkers()
private
static escapeMarkers(string $html) : string
Parameters
- $html : string
Return values
string —essentialsTags()
Replace the framework's layout-essentials closure calls with the Blade components the framework provides for them (resolved via a shared anonymous-component path), so a layout carries no raw essentials PHP.
private
static essentialsTags(string $tpl) : string
The components sit under the framework's own "zubzet" component namespace so an app component cannot shadow them by accident. $opt"layout_essentials_head" -> <x-zubzet::head :opt="$opt"/> $opt"layout_essentials_body" -> <x-zubzet::body :opt="$opt"/>
Parameters
- $tpl : string
Return values
string —extractClosure()
private
static extractClosure(string $source, string $key) : array<string|int, mixed>
Parameters
- $source : string
- $key : string
Return values
array<string|int, mixed> —section()
Section body: keep its indentation (it nests under @section), trim blank edges.
private
static section(string $content) : string
Parameters
- $content : string
Return values
string —yieldCall()
Replace a call to a layout closure param (`<?= $body($opt) ?>`, the "echo" form or a bare statement form) with the matching @yield.
private
static yieldCall(string $tpl, string|null $var, string $section) : string
Parameters
- $tpl : string
- $var : string|null
- $section : string