FunctionHandler
FunctionHandler
View template function bridge handler.
class FunctionHandler extends \Hazaar\Template\Smarty\HandlerExtends: Hazaar\Template\Smarty\Handler
This handler exposes framework view helpers and utility functions to template execution contexts. It acts as a dynamic dispatcher for helper calls and provides convenience methods for layout rendering, URL generation, date/time formatting, and configuration injection into the active view scope.
Properties
view
Active view instance used for helper lookup and context mutation.
private View $viewType: Hazaar\View
Methods
__construct
Create a new function handler bound to a view.
public __construct(View $view): voidParameters
| Parameter | Type | Description |
|---|---|---|
$view | Hazaar\View | view instance associated with this handler |
__default
Dynamically calls a method on a view helper.
public __default(string $name, array $args): ?stringReturns: string
Attempts to retrieve a helper by name from the view. If the helper exists, it calls the specified method (defaulting to 'render' if not provided) with the given arguments. Returns the result as a string, or null if the helper or method does not exist.
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | the name of the helper to retrieve |
$args | array | Arguments to pass to the helper method. The first argument can optionally specify the method name. |
layout
Returns the layout content if the current view is an instance of Layout.
public layout(): stringReturns: string
url
Generates a URL based on the provided controller, action, parameters, and absolute flag.
public url(?string $controller, ?string $action, array $params): URLReturns: Hazaar\Application\URL
Parameters
| Parameter | Type | Description |
|---|---|---|
$controller | string | the name of the controller |
$action | string | the name of the action |
$params | array | an array of parameters to be included in the URL |
date
Returns a date string formatted to the current set date format.
public date(DateTime|string $date = 'now'): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$date | Hazaar\Util\DateTime | string |
time
Returns a time string formatted to the current set time format.
public time(DateTime|string $time = 'now'): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$time | Hazaar\Util\DateTime | string |
timestamp
Return a date/time type as a timestamp string.
public timestamp(DateTime|string $value = 'now'): stringReturns: string
This is for making it quick and easy to output consistent timestamp strings.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | Hazaar\Util\DateTime | string |
datetime
Return a formatted date as a string.
public datetime(mixed $value = 'now', ?string $format): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed | This can be practically any date type. Either a \Hazaar\Util\DateTime object, epoch int, or even a string. |
$format | string | Optionally specify the format to display the date. Otherwise the current default is used. |
config
Loads a configuration file and sets a key-value pair in the view if the key exists.
public config(string $file, ?string $name, ?string $key): voidReturns: void
Opens the specified configuration file, retrieves the value for the given key, and if the value is not null, sets it in the view context under the same key.
Parameters
| Parameter | Type | Description |
|---|---|---|
$file | string | the configuration file to open |
$name | string | the name of the configuration section to retrieve (optional) |
$key | string | the key under which to set the retrieved value in the view context (optional, defaults to the name of the configuration section) |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:17 +0000