VuFind API Documentation

Context extends AbstractHelper
in package

Context manager (useful for using render() instead of partial() for better performance -- this allows us to set and roll back variables in the global scope instead of relying on the overhead of building a whole new scope).

Tags
category

VuFind

author

Demian Katz demian.katz@villanova.edu

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link

Wiki

Table of Contents

__invoke()  : Context
Grab the helper object, so we can call methods on it.
apply()  : array<string|int, mixed>
Set an array of variables in the view; return the previous values of those variables so they can be restored.
renderInContext()  : string
Render a template using a temporary context; restore the view to its original state when done. This offers the template full access to the global scope, modified by $context, then puts the global scope back the way it was.
restore()  : void
Restore an old context returned by apply().

Methods

__invoke()

Grab the helper object, so we can call methods on it.

public __invoke([RendererInterface|null $view = null ]) : Context
Parameters
$view : RendererInterface|null = null

View object to modify.

Return values
Context

apply()

Set an array of variables in the view; return the previous values of those variables so they can be restored.

public apply(array<string|int, mixed> $vars) : array<string|int, mixed>
Parameters
$vars : array<string|int, mixed>

Variables to set

Return values
array<string|int, mixed>

renderInContext()

Render a template using a temporary context; restore the view to its original state when done. This offers the template full access to the global scope, modified by $context, then puts the global scope back the way it was.

public renderInContext(string $template, array<string|int, mixed> $context) : string
Parameters
$template : string

Template to render

$context : array<string|int, mixed>

Array of context variables to set temporarily

Return values
string

Rendered template output

restore()

Restore an old context returned by apply().

public restore(array<string|int, mixed> $vars) : void
Parameters
$vars : array<string|int, mixed>

Variables to set

Return values
void

Search results