Documentation

Class Phalcon\Mvc\View\Model

extends abstract class Phalcon\Di\Injectable

implements Phalcon\Events\EventsAwareInterface, Phalcon\Di\InjectionAwareInterface, Phalcon\Mvc\View\ModelInterface

Source on GitHub

This component allows to render views without hicherquical levels

<?php

 $view = new Phalcon\Mvc\View\Model();
 echo $view->render('templates/my-view', array('content' => $html));

Methods

public __construct ([unknown $vars], [unknown $template], [unknown $capture])

Phalcon\Mvc\View\Model constructor

public Phalcon\Mvc\View\ModelInterface setTemplate (string $template)

Set the template to be used by this model

public string getTemplate ()

Get the template to be used by this model

public Phalcon\Mvc\View\ModelInterface setVars (array $params, [boolean $merge])

Set all the render params

public string getVars ()

Get the vars

public Phalcon\Mvc\View\ModelInterface setVar (string $key, mixed $value)

Set a single view parameter

public mixed getVar (string $key, [unknown $default_value])

Get the vars

public Phalcon\Mvc\View\ModelInterface addChild (unknown $viewmodel, [unknown $name], [unknown $append])

Add a child model

public Phalcon\Mvc\View\ModelInterface appendChild (unknown $viewmodel, [unknown $name])

Append a child model

public array getChild (unknown $name)

Return a child model or all child model

public boolean hasChild ()

Does the model have any children?

public Phalcon\Mvc\View\ModelInterface setCaptureTo (string $capture)

Set the name of the variable to capture this model to, if it is a child model

public string getCaptureTo ()

Get the name of the variable to which to capture this model

public Phalcon\Mvc\View\ModelInterface setTerminal (boolean $terminate)

Set flag indicating whether or not this is considered a terminal or standalone model

public boolean getTerminal ()

Is this considered a terminal or standalone model?

public Phalcon\Mvc\View\ModelInterface setAppend (boolean $append)

Set flag indicating whether or not append to child with the same capture

public boolean isAppend ()

Is this append to child with the same capture?

public Phalcon\Mvc\View\ModelInterface setView (Phalcon\Mvc\ViewInterface $view)

Set the view

public Phalcon\Mvc\ViewInterface getView ()

Get the view

public string render ()

Renders the view

public __set (unknown $property, mixed $value)

Magic method to pass variables to the views

public mixed __get (unknown $property)

Magic method to retrieve a variable passed to the view

public boolean __isset (unknown $property)

Magic method to inaccessible a variable passed to the view

public __toString ()

...

public setDI (Phalcon\DiInterface $dependencyInjector) inherited from Phalcon\Di\Injectable

Sets the dependency injector

public Phalcon\DiInterface getDI ([unknown $error], [unknown $notUseDefault]) inherited from Phalcon\Di\Injectable

Returns the internal dependency injector

public setEventsManager (Phalcon\Events\ManagerInterface $eventsManager) inherited from Phalcon\Di\Injectable

Sets the event manager

public Phalcon\Events\ManagerInterface getEventsManager () inherited from Phalcon\Di\Injectable

Returns the internal event manager

public boolean fireEvent (string $eventName, [mixed $data], [unknown $cancelable]) inherited from Phalcon\Di\Injectable

Fires an event, implicitly calls behaviors and listeners in the events manager are notified

public mixed fireEventCancel (string $eventName, [mixed $data], [unknown $cancelable]) inherited from Phalcon\Di\Injectable

Fires an event, can stop the event by returning to the false

public boolean hasService (string $name) inherited from Phalcon\Di\Injectable

Check whether the DI contains a service by a name

public Phalcon\Di\ServiceInterface setService (unknown $name) inherited from Phalcon\Di\Injectable

Sets a service from the DI

public object|null getService (unknown $name) inherited from Phalcon\Di\Injectable

Obtains a service from the DI

public mixed getResolveService (string $name, [array $args], [unknown $noerror], [unknown $noshared]) inherited from Phalcon\Di\Injectable

Resolves the service based on its configuration

public attachEvent (string $eventType, Closure $callback) inherited from Phalcon\Di\Injectable

Attach a listener to the events

public __sleep () inherited from Phalcon\Di\Injectable

...

public __debugInfo () inherited from Phalcon\Di\Injectable

...