I want to redeclare and add some methods to helper Tag.
class MyTags extends \Phalcon\Tag
{
public static function mytag($params)
{
<...>
}
}
in services.php
$di->set('tag', function() {
return new MyTags();
};
But it works only for PHP engine, not for Volt.
{{ mytag() }}
returned
Undefined function 'mytag'
First of all: don't use
tag
as your service name because it's already used by Phalcon's Tag object. Secondly you can use static methods from class.Below is a working example for
myTag
using config from my app with changed names for your example.Then you can use your
myTag()
function in volt views.But if you want to use object then don't use static methods:
in services use object:
and then in in volt: