Completed
Push — master ( 60e303...4c478a )
by
unknown
8s
created

src/Tasks/CleanupGeneratedPdfDailyTask.php (1 issue)

1
<?php
2
3
namespace CWP\PDFExport\Tasks;
4
5
use SilverStripe\Core\Config\Configurable;
6
use SilverStripe\Core\Injector\Injector;
7
use SilverStripe\CronTask\Interfaces\CronTask;
0 ignored issues
show
The type SilverStripe\CronTask\Interfaces\CronTask was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
if (!interface_exists(CronTask::class)) {
10
    return;
11
}
12
13
/**
14
 * If the silverstripe/crontask module is installed, this will enable the PDF cleanup task to be run on a schedule
15
 */
16
class CleanupGeneratedPdfDailyTask implements CronTask
17
{
18
    use Configurable;
19
20
    /**
21
     * The cron schedule for this task (default: midnight every day)
22
     *
23
     * @config
24
     * @var string
25
     */
26
    private static $schedule = '0 0 * * *';
27
28
    /**
29
     * Whether this task is enabled (default false)
30
     *
31
     * @config
32
     * @return bool
33
     */
34
    private static $enabled = false;
35
36
    private static $segment = 'CleanupGeneratedPdfDailyTask';
37
38
    public function getSchedule()
39
    {
40
        return $this->config()->get('schedule');
41
    }
42
43
    public function process()
44
    {
45
        if (!$this->config()->get('enabled')) {
46
            return;
47
        }
48
49
        $task = Injector::inst()->create(CleanupGeneratedPdfBuildTask::class);
50
        $task->run(null);
51
    }
52
}
53