André Luiz André Luiz - 1 month ago 6x
PHP Question

Phalcon PhP - Unkown filter

I'm trying to create custom filter for currency so I can use in my .volt templates. This is how I register the filter in my services.php

$di->setShared('filter', function() {
$filter = new \Phalcon\Filter();
$filter->add('currency', function ($value) {
if($value === '') {
return NULL;
} else {
return $value; // @todo implement the currency formatting
return $filter;

Then when I try to use it in my .volt template, like this
{{ quote['total_fees']|currency }}
I get the following message
Unknown filter "currency"

Can you see what I'm doing wrong?

Thanks for any help


I think i already posted link, but okay, here you go again - It should look like this:

$di->set('view', function() {
    $view = new View();
        '.volt' => function($view, $di) {
            $volt = new Volt($view, $di);
            $compiler = $volt->getCompiler();
            $compiler->addFilter('currency',your code);
    return $view;