class ViewService (View source)

Provide general view-related functionality.

Methods

array
getGlobals()

Get global variables.

void
addGlobal(string $key, mixed $value)

Set a global variable.

void
addGlobals(array $globals)

Set an array of global variables.

getComposersForView(string $view)

Get view composer.

void
addComposer(string|string[] $views, string|Closure $composer)

Add view composer.

void
compose(ViewInterface $view)

Get the composed context for a view.

make(string|string[] $views)

Create a view instance.

void
triggerPartialHooks(string $name)

Trigger core hooks for a partial, if any.

Details

array getGlobals()

Get global variables.

Return Value

array

void addGlobal(string $key, mixed $value)

Set a global variable.

Parameters

string $key
mixed $value

Return Value

void

void addGlobals(array $globals)

Set an array of global variables.

Parameters

array $globals

Return Value

void

Handler[] getComposersForView(string $view)

Get view composer.

Parameters

string $view

Return Value

Handler[]

void addComposer(string|string[] $views, string|Closure $composer)

Add view composer.

Parameters

string|string[] $views
string|Closure $composer

Return Value

void

Exceptions

Exception

void compose(ViewInterface $view)

Get the composed context for a view.

Passes all arguments to the composer.

Parameters

ViewInterface $view

Return Value

void

ViewInterface make(string|string[] $views)

Create a view instance.

Parameters

string|string[] $views

Return Value

ViewInterface

void triggerPartialHooks(string $name)

Trigger core hooks for a partial, if any.

Parameters

string $name

Return Value

void