class View

Properties

static int $parsing_progressive

Progressive counter for parsing operations.

static array $available_source_paths

List of available source paths for views.

static array $available_modules_source_paths

Methods

__construct(string $view_path = "", array $args = [])

Creates a new instance.

static 
addModuleSourcePath(string $path, string $namespace)

Adds a source path for modules views with a namespace.

static 
addSourcePath(string $path, string|null $namespace = null)

Adds a source path for views, optionally with a namespace.

static 
initSourcePaths()

Initialize all source paths from configuration.

static 
notFound(string $view)

Throw an exception when a view is not found

static bool
exists(string $path)

Check if a view exists

static View
module(string $filename, array $args = [])

Get a module view from filename

static View
get(string $filename, array $args = [])

Get a view from filename

string
getPath()

Get the view path

array
getArguments()

Get the view arguments

parent(View $parent)

Set the view parent

section(string $name, string|null $default = null)

Set section position inside the view

start_style()

Starts style section.

stop_style(array|null $options = [])

Stops style section.

start_script()

Starts script section.

stop_script(array|null $options = [])

Stops script section.

start_section(string $name, string|null $content = null)

Starts a section.

stop_section()

Stops a section.

mergeSections(array $sections)

Merge view sections content with given sections content

setSectionContent(string $name, string $content)

Sets the section content

string
compile()

Compile the view content

string
build()

Resolve and build the view.

render()

Build and print the view.

string
__toString()

Returns a string representation of the object.

Details

at line 71
__construct(string $view_path = "", array $args = [])

Creates a new instance.

Parameters

string $view_path

The view path

array $args

The view arguments

at line 87
static addModuleSourcePath(string $path, string $namespace)

Adds a source path for modules views with a namespace.

Parameters

string $path

The path to add as a source for modules views.

string $namespace

The namespace for the views.

Exceptions

Exception

at line 102
static addSourcePath(string $path, string|null $namespace = null)

Adds a source path for views, optionally with a namespace.

Parameters

string $path

The path to add as a source for views.

string|null $namespace

The namespace for the views (optional).

Exceptions

Exception

at line 119
static initSourcePaths()

Initialize all source paths from configuration.

Loads view paths from the configuration and registers them for each section.

See also

config("views.paths")

at line 132
static notFound(string $view)

Throw an exception when a view is not found

Parameters

string $view

The view

Exceptions

Exception

at line 143
static bool exists(string $path)

Check if a view exists

Parameters

string $path

The view path without file extension

Return Value

bool

True if found, False otherwise

at line 155
static View module(string $filename, array $args = [])

Get a module view from filename

Parameters

string $filename

The view filename

array $args

The view arguments

Return Value

View

at line 190
static View get(string $filename, array $args = [])

Get a view from filename

Parameters

string $filename

The view filename

array $args

The view arguments

Return Value

View

at line 226
string getPath()

Get the view path

Return Value

string

The view path

at line 235
array getArguments()

Get the view arguments

Return Value

array

The view arguments

at line 244
parent(View $parent)

Set the view parent

Parameters

View $parent

Parent view

at line 254
section(string $name, string|null $default = null)

Set section position inside the view

Parameters

string $name

The section name

string|null $default

Default content

at line 261
start_style()

Starts style section.

at line 274
stop_style(array|null $options = [])

Stops style section.

Parameters

array|null $options

Section options

at line 311
start_script()

Starts script section.

at line 324
stop_script(array|null $options = [])

Stops script section.

Parameters

array|null $options

Section options

at line 366
start_section(string $name, string|null $content = null)

Starts a section.

Parameters

string $name

The section name

string|null $content

at line 378
stop_section()

Stops a section.

at line 390
mergeSections(array $sections)

Merge view sections content with given sections content

Parameters

array $sections

Sections to merge

at line 405
setSectionContent(string $name, string $content)

Sets the section content

If the section does not exist it will be first filled with an empty string. If it exists, and a child view has a section with the same name, it is concatenated to have the order parent + child.

Parameters

string $name

Section name

string $content

Section content

at line 420
string compile()

Compile the view content

Return Value

string

The compiled content

at line 434
string build()

Resolve and build the view.

Return Value

string

The resultg view

at line 447
render()

Build and print the view.

at line 458
string __toString()

Returns a string representation of the object.

When you print the \App\System\MVC\View object Eg. using echo

Return Value

string

String representation of the object.