trait ViewMaker

Properties

array $vars
array $viewPath
array $layoutPath
array $partialPath
string $layout
bool $suppressLayout
protected $viewFileExtension

Methods

getViewPath($view, $viewPath = null)

No description

guessViewFileExtension($path)

No description

string
guessViewPath(string $suffix = '', bool $isPublic = false)

Guess the package path from a specified class.

mixed
makeLayout(string $name = null, array $vars = [], bool $throwException = true)

Render a layout.

string
makeView(string $view)

Loads a view with the name specified.

mixed
makePartial(string $partial, array $vars = [], bool $throwException = true)

Render a partial file contents located in the views or partial folder.

string
makeFileContent(string $filePath, array $extraParams = [])

Includes a file path using output buffering.

compileFileContent($filePath)

No description

void
handleViewException(Exception $e, int $obLevel)

Handle a view exception.

array
gatherViewData($data)

Get the data bound to the view instance.

Details

at line 50
getViewPath($view, $viewPath = null)

No description

Parameters

$view
$viewPath

at line 78
guessViewFileExtension($path)

No description

Parameters

$path

at line 98
string guessViewPath(string $suffix = '', bool $isPublic = false)

Guess the package path from a specified class.

Parameters

string $suffix

An extra path to attach to the end

bool $isPublic

Return Value

string

at line 119
mixed makeLayout(string $name = null, array $vars = [], bool $throwException = true)

Render a layout.

Parameters

string $name

Specifies the layout name. If this parameter is omitted, the $layout property will be used.

array $vars

Parameter variables to pass to the view.

bool $throwException

Throw an exception if the layout is not found

Return Value

mixed

The layout contents, or false.

Exceptions

SystemException

at line 147
string makeView(string $view)

Loads a view with the name specified.

Applies layout if its name is provided by the parent object. The view file must be situated in the views directory, and has the extension "htm" or "php".

Parameters

string $view

Specifies the view name, without extension. Eg: "index".

Return Value

string

at line 171
mixed makePartial(string $partial, array $vars = [], bool $throwException = true)

Render a partial file contents located in the views or partial folder.

Parameters

string $partial

The view to load.

array $vars

Parameter variables to pass to the view.

bool $throwException

Throw an exception if the partial is not found.

Return Value

mixed

Partial contents or false if not throwing an exception.

Exceptions

SystemException

at line 199
string makeFileContent(string $filePath, array $extraParams = [])

Includes a file path using output buffering.

Ensures that vars are available.

Parameters

string $filePath

Absolute path to the view file.

array $extraParams

Parameters that should be available to the view.

Return Value

string

at line 235
compileFileContent($filePath)

No description

Parameters

$filePath

at line 256
protected void handleViewException(Exception $e, int $obLevel)

Handle a view exception.

Parameters

Exception $e
int $obLevel

Return Value

void

at line 271
protected array gatherViewData($data)

Get the data bound to the view instance.

Parameters

$data

Return Value

array