$internalViewData
$internalViewData : array
The data assigned to this view. Usually, a controller will be responsible for passing data to the view object using the assign() method.
A simple view implementation that allows for simple assignment of data, escaping for common contexts (e.g. HTML, HTML attribute, JS, etc.), and calling of helper objects for reusable view logic.
Including method annotations here (http://www.phpdoc.org/docs/latest/references/phpdoc/tags/method.html) to assist static analysis in PHPStorm and Scrutinizer CI given the use of the __call() magic method in this class for view helpers. Won't cover us on custom helpers necessarily, but it will help catch most bugs/typos.
$request : \Dewdrop\Request
The current HTTP request.
__construct(\Zend\Escaper\Escaper $escaper = null, \Dewdrop\Request $request = null)
Create a new view, optionally supplying an escaper object for use in sanitizing output in various contexts.
\Zend\Escaper\Escaper | $escaper | |
\Dewdrop\Request | $request |
assign(string|array $name, mixed $value = null) : \Dewdrop\View\View
Assign variables to this view's data.
If the $name parameter is an array rather than a string, assign() will iterate over it, assigning variables for each key-value pair. For example, passing the following array would assign 3 different data variables:
$this->assign( array( 'var1' => 1, 'var1' => 2, 'var1' => 3 ) );
string|array | $name | |
mixed | $value |
assignInstance(string $name, object $instance) : $this
Assign a helper instance to the supplied name, rather than requiring that it be instantiated when the helper is accessed. Typically used to share helper instances with partials generated by a parent view, which reduces resource usage and allows things like CSS and JS added by partials to propagate intuitively.
string | $name | |
object | $instance |
registerHelper(string $name, string $className) : \Dewdrop\View\View
Register a new helper name and class name. This can be used to replace a default helper implementation or to introduce a project-specific helper.
string | $name | |
string | $className | The full class name/namespace. |
__get(string $name) : mixed
Retrieve the named index from the $data property or return null. This makes it easier to avoid undefined variable notices in your view scripts because you don't have to be quite so circumspect in ensuring variables are set before checking them.
string | $name |
__set(string $name, mixed $value) : \Dewdrop\View\View
Delegate assignment to unknown class properties to the assign() method.
string | $name | |
mixed | $value |
__call(string $method, array $args) : \Dewdrop\View\Helper\AbstractHelper
When calling an unknown method on this view, pass the method name to the helper() method and call the helper's direct() method. Using the __call() magic method in this way allows using helpers in this manner:
$this->helperName('arg1', $arg2);
Rather than having to call an additional method on the helper like this:
$this->helper('helperName')->direct('arg1', $arg2);
If the direct() method is unavailable, the helper instance is returned instead.
string | $method | |
array | $args |
helper(string $name) : \Dewdrop\View\Helper\AbstractHelper
Get the helper matching the provided named.
string | $name |
partial(string $template, array $data, string $scriptPath = null) : string
Render a partial view. By default, the same script path used by this view is passed along. This escaper from this view is also passed to the partial.
string | $template | |
array | $data | |
string | $scriptPath |
getRequest() : \Dewdrop\Request
Get the current Request object for access to GET or POST data from helpers.
setScriptPath(string $path) : \Dewdrop\View\View
Set the path in which to look for view scripts.
string | $path |
render(string $template) : string
Render the provided template file.
The file's name should end in .phtml and be present in the assigned script path. This method returns the output as a string so that you have the opportunity to filter or otherwise handle it prior to actually adding it to the response.
string | $template |
renderFullPathTemplate(string $template) : string
Render the provided template file.
This method returns the output as a string so that you have the opportunity to filter or otherwise handle it prior to actually adding it to the response.
string | $template | Full path of file |
instantiateHelper(string $name) : \Dewdrop\View\Helper\AbstractHelper
Create an instance of helper associated with the provided name and store that instance in the $helpers property so that it can be retrieved on any subsequent calls.
string | $name |
castEscaperStringValue(mixed $input) : string
\Zend\Escaper\Escaper does not play well with falsey non-string values like null or false. It throws exceptions claiming it cannot convert them to utf-8. This method will convert false and null to an empty string and then cast the return value to a string (which should catch ints and floats as well).
mixed | $input |