I have a Phalcon volt template I wanted to call in my custom helper, it will accept an array but the array sent to the helper is of string type.
In my list.volt I have this code,
{% set myfolder = data.foldername %}
{% set key = data.folderkey %}
{% set url = convert([myfolder, key]) %}
In my loader.php, I have declared the helper directory and have this code:
//$params should be single dimensional array
$compiler->addFunction('convert', function($params){
var_dump($params);
return MyCustomHelper::convert($params);
});
Will output string(31) "array($fname, $fkey)"
instead of an array type. It made my helper stop working.
Anyone face this, I need it to be of an array type not string?
UPDATE: After applying @Nikolay Mihaylov suggestion.
Got an error
Fatal error: Class 'MyCustomUrlHelper' not found in cache/volt/%apps%%invo%%views%%test%%list.volt.php on line 56
In my services.php, I've included my helper directory
use Modules\Library\MyCustomUrlHelper;
/*
......
Some code here
..............................
....................
*/
$compiler->addFunction('convert', function($resolvedArgs, $exprArgs){
return 'MyCustomUrlHelper::convert('.$resolvedArgs.')';
});
In loader.php, i've registered the directory
........
.....................
$loader->registerDirs(array(APP_PATH.'Modules/Library'))->register();
...................
........................
In my Modules/Library directory, i have this MyCustomUrlHelper.php
<?php
namespace Modules\Library;
use Phalcon\Tag;
class MyCustomUrlHelper extends Tag
{
public function convert($params)
{
if(!is_array($params))
{
$params = array($params);
}
/*
..... some code here ...
.................
..........
*/
return $converted;
}
}
?>
Did i miss something else?