summaryrefslogtreecommitdiffstats
path: root/lib/Migration/RemoveUnusedJob.php
blob: cb5c5fecc9767b67c1d4d121a20a704e90080a29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace OCA\News\Migration;

use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
use Psr\Log\LoggerInterface;
use OCP\BackgroundJob\IJobList;

class RemoveUnusedJob implements IRepairStep
{
    
    /**
     * @var LoggerInterface
     */
    protected $logger;
    
    /**
     * @var IJobList
     */
    protected $joblist;
    
    public function __construct(LoggerInterface $logger, IJobList $jobList)
    {
        
        $this->logger = $logger;
        $this->joblist = $jobList;
    }
    
    /**
     * Returns the step's name
     */
    public function getName()
    {
        return 'Remove the unused News update job';
    }
    
    /**
     * @param IOutput $output
     */
    public function run(IOutput $output)
    {
        if ($this->joblist->has("OCA\News\Cron\Updater", null)) {
            $output->info("Job exists, attempting to remove");
            $this->joblist->remove("OCA\News\Cron\Updater");
            $output->info("Job removed");
        } else {
            $output->info("Job does not exist, all good");
        }
    }
}