interface ViewInterface (View source)

Interface of a view

Methods

void
setControllerContext(ControllerContext $controllerContext)

Sets the current controller context

assign(string $key, mixed $value)

Add a variable to the view data collection.

assignMultiple(array $values)

Add multiple variables to the view data collection

bool
canRender(ControllerContext $controllerContext)

Tells if the view implementation can render the view for the given context.

string|ActionResponse|ResponseInterface|StreamInterface|object
render()

Renders the view

static ViewInterface
createWithOptions(array $options)

Factory method to create an instance with given options.

Details

void setControllerContext(ControllerContext $controllerContext)

Sets the current controller context

Parameters

ControllerContext $controllerContext

Context of the controller associated with this view

Return Value

void

ViewInterface assign(string $key, mixed $value)

Add a variable to the view data collection.

Can be chained, so $this->view->assign(..., ...)->assign(..., ...); is possible

Parameters

string $key

Key of variable

mixed $value

Value of object

Return Value

ViewInterface

an instance of $this, to enable chaining

ViewInterface assignMultiple(array $values)

Add multiple variables to the view data collection

Parameters

array $values

array in the format array(key1 => value1, key2 => value2)

Return Value

ViewInterface

an instance of $this, to enable chaining

bool canRender(ControllerContext $controllerContext)

Tells if the view implementation can render the view for the given context.

Parameters

ControllerContext $controllerContext

Return Value

bool

true if the view has something useful to display, otherwise false

string|ActionResponse|ResponseInterface|StreamInterface|object render()

Renders the view

Return Value

string|ActionResponse|ResponseInterface|StreamInterface|object

The rendered result; object is only handled if __toString() exists!

static ViewInterface createWithOptions(array $options)

Factory method to create an instance with given options.

Parameters

array $options

Return Value

ViewInterface