XF 2.2 Calling an addons service from cron

Dannymh

Active member
My addon that I am writing has a service which generates PDF documents. I need this to be run by a cron at regular intervals and will generate the PDF files for me. What I am struggling with is just how I would call that service from the cron?

would it simply be the following?
PHP:
\XF::app()->service('myaddon:theService', $arg1, $arg2, $arg3);
 
You'd call it however you'd call it from a controller or anywhere else. That code would jut create an instance of the service, it wouldn't do anything unless your logic is in the __construct. Services would have functions in them you can all.

PHP:
$pdfService = \XF::app()->service('myaddon:theService', $arg1, $arg2, $arg3);
$pdfService->generate();
 
Back
Top Bottom