Janitor guide
The Janitor module allows an app to program tasks to be executed periodically.
Setting up the Janitor database table
Janitor tasks
<?php
namespace CherrycakeApp;
class JanitorTaskMoviesUpdateImdbRating extends \Cherrycake\Janitor\JanitorTask {
protected $name = "Movies update IMDB rating";
protected $description = "Updates the IMDB rating of all the movies in the database";
protected $config = [
"executionPeriodicity" => \Cherrycake\Janitor\JANITORTASK_EXECUTION_PERIODICITY_HOURS,
"periodicityHours" => ["00:00"]
];
function run($baseTimestamp) {
global $e;
$e->loadCoreModule("Database");
$movies = new Movies(["fillMethod" => "fromParameters"]);
foreach ($movies as $movie)
$movie->updateImdbRating();
return [
\Cherrycake\Janitor\JANITORTASK_EXECUTION_RETURN_OK,
$movies->count()." movies updated"
];
}
}Adding Janitor tasks to be executed
Cherrycake core Janitor tasks
Setting up the Janitor cron job
Checking the status of the Janitor
Last updated