We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Config Yaml - not accepting callback array (Wrong number of parameters)

I have got installed Incubator 1.3.0 dev and a code like below:

    $data = new \Phalcon\Config\Adapter\Yaml($file, array(
                            '!decrypt' => function($value) {
                                return (new \Phalcon\Crypt)->setCipher('blowfish')->decryptBase64($value, SECRET);
                            },
                            '!approot' => function($value) {
                                return ROOT_PATH . $value;
                            }
                        ));

The problem which I have is that I am getting this error:

    Fatal error: Uncaught exception 'BadMethodCallException' with message 'Wrong number of parameters' in ...../app/engine/Config.php:86

Does anyone maybe know how can I sort this, as it would be nice to have got encrypted passwords in configuration files.



6.2k

The problems seems to be that in Phalcon 1.3.2 there is already included Phalcon\Config\Adapter\Yaml but I can pass to there just a filename but not callback. Is there a way that I could use Yaml Adapter from Incubator instead of the one build in Phalcon 1.3.2?



8.1k
Accepted
answer
edited Jun '14

@marek1989 Just rename the incubator Adapter class to something else.. (e.g. YamlIncubator, Yaml2, ...) Or alternatively you could change the namespace...

(I had to do the same thing for Translate\Adapter\Gettext)

btw - It would be great if we could somehow direct the framework to use the (custom) class from disk/ Incubator instead of the one from the extension... Not sure if that could be possible technically.



6.2k

@renskii I was thinking about this, but what will happen after runing composer update? Is it not gonna be deleted?



8.1k

I am not sure... I just copied what I needed from the Incubator manually... So yes, I guess it's a bit of an issue when using/ relying on Composer?

I think it's a bit pitful that these changes / updates aren't further commented on or discussed by the team. (We're figuring this out on our own now.)



6.2k
edited Jun '14

That is true @renskii, especially that Incubator is developed by @Phalcon team, so I would say that this should be removed from Incubator and all those parameters for Yaml should be moved into main Phalcon repository.

Thanks anyway for help.