XF 2.2 Pass data instead form

Robert9

Well-known member
I have an addon with a form, getting data, do something in
pub/controller/index

public function actionIncoming(ParameterBag $params)
{
$input = $this->filter([
'lala' => 'str'
]);




Now i want to have a cron-job do the same, but with data from a table instead an input.

I try

$params = [
'lala'=> "something",
];

$result = \Example\Pub\Controller\Index::actionIncoming($params);


and get

TypeError: Argument 1 passed to Example\Pub\Controller\Index::actionIncoming() must be an instance of XF\Mvc\ParameterBag


What i have to do now with $params to make XF happy, please?
 
Last edited:
Move the code that does the "work" from your controller into a method in a separate object (could be a repository or just any sort of separate object). Have your controller code call that, receiving the necessary input via an array. You'd create this via filter() as your code already shows.

Now you can call that from a cron job with its own $params array and everything should work.
 
Thank you, i will try.
To have a running addon i have now copied all the neded code in job/work.php to let the cron-job run.

Is it true that some things can be done only at the right place?
It seems to me that $this->plugin( is used only in files in /pub/controller for example.


And from above:

$params = [
'lala'=> "something",
];

was in /job/example.php


I will try later again and post the code;
 
Back
Top Bottom