I found that view variables in phalcon could be escaped by Phalcon\Escaper: http://docs.phalconphp.com/en/latest/api/Phalcon_Escaper.html
For example, in Zend, there is a way to call view helpers from view:
// view context
$this->escape($data); // calls View\Helper\Escape
$this->url($params); // calls url view helper
// etc
Is there a way to get such view helpers without creating new object every time? My current idea is to make some BaseView class, extended from Phalcon\Mvc\View and to define some often-used methods there, that will use cached objects.. but i am not sure that it is the best way:
class BaseView extends Phalcon\Mvc\View
{
// cached helper objects
$helpers = [];
// view helper call
public function url($params)
{
if (!$this->helpers['url']) {
$this->helpers['url'] = new Phalcon\Mvc\Url();
}
return $this->helpers['url']->get($params);
}
}