class ViewService (View source)

Provide general view-related functionality.

Methods

__construct(array $config, ViewEngineInterface $engine, HandlerFactory $handler_factory)

Constructor.

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)

Composes a view instance with contexts in the following order: Global, Composers, Local.

make(string|string[] $views)

Create a view instance.

void
triggerPartialHooks(string $name)

Trigger core hooks for a partial, if any.

void
render(string|string[] $views, array $context = [])

Render a view.

Details

__construct(array $config, ViewEngineInterface $engine, HandlerFactory $handler_factory)

Constructor.

Parameters

array $config mixed> $config
ViewEngineInterface $engine
HandlerFactory $handler_factory

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

void compose(ViewInterface $view)

Composes a view instance with contexts in the following order: Global, Composers, Local.

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

void render(string|string[] $views, array $context = [])

Render a view.

Parameters

string|string[] $views
array $context mixed> $context

Return Value

void