ViewRenderer
ViewRenderer
Class ViewRenderer.
- Full name:
\Hazaar\Controller\Action\ViewRenderer
- This class implements:
\ArrayAccess
Properties
view
private ?\Hazaar\View $view
_data
private array<string,mixed> $_data
Methods
__set
public __set(string $key, mixed $value): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$key | string | |
$value | mixed |
__isset
public __isset(string $name): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string |
__unset
public __unset(string $name): void
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string |
exec
public exec(\Hazaar\Controller\Response\HTML $response): void
Parameters:
Parameter | Type | Description |
---|---|---|
$response | \Hazaar\Controller\Response\HTML |
addHelper
Adds a helper to the view renderer.
public addHelper(string $helper, array $args = [], null|string $alias = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$helper | string | the name of the helper to add |
$args | array | an optional array of arguments to pass to the helper |
$alias | null|string | an optional alias for the helper |
Return Value:
the added ViewHelper instance, or null if the view is not set
getHelpers
Retrieves the helpers associated with the current view.
public getHelpers(): \Hazaar\View\Helper[]
Return Value:
an array of helpers or null if no view is set
removeHelper
Removes a helper from the view renderer.
public removeHelper(string $name): void
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string | the name of the helper to remove |
__get
Magic method to get the value of a property.
public __get(string $key): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$key | string | the name of the property to get |
Return Value:
the value of the property
populate
Populates the view renderer with data.
public populate(array $array): void
Parameters:
Parameter | Type | Description |
---|---|---|
$array | array | the array of data to populate the view renderer with |
extend
Extends the data available on any defined views.
public extend(array $array): void
Parameters:
Parameter | Type | Description |
---|---|---|
$array | array | the array of data to extend the view renderer with |
hasView
Checks if a view exists.
public hasView(string $view): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$view | string | the name of the view to check |
Return Value:
returns true if the view exists, false otherwise
layout
Sets the layout for the view.
public layout(\Hazaar\View\Layout|string $view): void
If the current view is an instance of Layout
, it loads the specified layout. Otherwise, if the specified layout is not an instance of Layout
, it creates a new Layout
instance. Finally, it sets the view to the specified layout.
Parameters:
Parameter | Type | Description |
---|---|---|
$view | \Hazaar\View\Layout|string | the layout or view to set |
setNoLayout
Sets the view renderer to disable layout rendering.
public setNoLayout(): void
This method sets the view property to null, which indicates that the layout rendering should be disabled. When the layout rendering is disabled, only the view template will be rendered without any surrounding layout.
view
Renders a view.
public view(string|\Hazaar\View $view): void
Parameters:
Parameter | Type | Description |
---|---|---|
$view | string|\Hazaar\View | The view to render. It can be either a string representing the view file path or an instance of the View class. |
render
public render(?\Hazaar\View $view = null): string
Parameters:
Parameter | Type | Description |
---|---|---|
$view | ?\Hazaar\View |
offsetExists
public offsetExists(mixed $offset): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$offset | mixed |
offsetGet
public offsetGet(mixed $offset): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$offset | mixed |
offsetSet
public offsetSet(mixed $offset, mixed $value): void
Parameters:
Parameter | Type | Description |
---|---|---|
$offset | mixed | |
$value | mixed |
offsetUnset
public offsetUnset(mixed $offset): void
Parameters:
Parameter | Type | Description |
---|---|---|
$offset | mixed |
renderView
Renders a view and returns the rendered output as a string.
private renderView(\Hazaar\View $view): string
Parameters:
Parameter | Type | Description |
---|---|---|
$view | \Hazaar\View | the view object to render |
Return Value:
the rendered output of the view
Automatically generated on 2024-11-14