$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.
This class helps you render a nice HTML template for an email using this template from Github:
The template has already been run through Premailer (http://premailer.dialect.ca/) so all of its styles are inlined and it is tested in a variety of mail clients. This view sub-class gives you a number of helpers that make it easier to add content to this template without having to ready the terrible markup and styles.
A typical view script would look like this:
echo $this->document()->open('My message title'); echo $this->content()->open(); echo $this->p('Hello, world!'); echo $this->h1('This is a header'); echo $this->h2('This is a slightly smaller header'); echo $this->button('CALL TO ACTION!', 'http://example.org/'); echo $this->content()->close(); // Unsubscribe or other footer content here echo $this->document()->close();
$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.
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 ) );
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.
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.
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.
__set(string $name, mixed $value) : \Dewdrop\View\View
Delegate assignment to unknown class properties to the assign() method.
__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:
Rather than having to call an additional method on the helper like this:
If the direct() method is unavailable, the helper instance is returned instead.
helper(string $name) : \Dewdrop\View\Helper\AbstractHelper
Get the helper matching the provided named.
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.
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.
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.
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.
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.
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).