You need to create the .task file as explained in the link.
Then create the task file itself, which if we follow the example from docs, at the very least needs this as base
<?php
namespace Xibo\Custom;
use Xibo\XTR\TaskInterface;
use Xibo\XTR\TaskTrait;
class CustomTask implements TaskInterface
{
use TaskTrait;
public function run()
{
// TODO: Implement run() method.
}
public function setFactories($container)
{
// TODO: Implement setFactories() method.
}
}
You can have a look at one of the existing tasks to see how the workflow should work.
Once you’re happy you can go to Task page in your CMS, click add Task and select your custom task from the dropdown, specify cron schedule and options if needed.
I have tried on last few versions of cms (3.0.3 and 2.3.11).
I have a very basic task for now as shown below.
<?php
namespace Xibo\Custom;
use Xibo\XTR\TaskInterface;
use Xibo\XTR\TaskTrait;
class CustomTask implements TaskInterface
{
use TaskTrait;
public function run()
{
$this->runMessage = "test" . PHP_EOL . PHP_EOL;
$this->log->debug("test");
}
}
Ever get this to work? Doesn’t work for us that’s for sure. And there is a complete lack of documentation on the website. Devs mention the .task file but nothing about the .php and how to implement it. They also have conflicting info depending on how far back in the forums you go
@dan
Instead of the skeleton function above, can you provide us with a working example either in here or on the Task page documentation (Tasks - Extend Xibo | Xibo Digital Signage)? You link to it even, and it’s very incomplete. As it stands right now, latest version of the CMS in a Docker container, and even the simplest of tasks outputs nothing to the log, other than it ran. Why does $this->log->debug(“Test info”) not actually do anything?
You’re absolutely right that we need to improve documentation for tasks, and our developer documentation more generally.
We use Monolog for logging, and you’re right the debug logs are only recorded when the CMS is in debug mode. For development it actually makes the most sense to put the CMS in “Test” mode via admin → settings, that way you get maximum logging and error output.
I will try to that! What are you actually trying to achieve with your task? perhaps I can tailor the example somewhat?