Passed
Push — master ( 9c2d70...6ef7ba )
by Roeland
10:28
created

SendEventReminders::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 5
rs 10
1
<?php
2
/**
3
 * @copyright Copyright (c) 2019, Georg Ehrke
4
 *
5
 * @author Georg Ehrke <[email protected]>
6
 *
7
 * @license AGPL-3.0
8
 *
9
 * This code is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License, version 3,
11
 * as published by the Free Software Foundation.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License, version 3,
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
20
 *
21
 */
22
namespace OCA\DAV\Command;
23
24
use OCA\DAV\CalDAV\Reminder\ReminderService;
25
use OCP\IConfig;
26
use Symfony\Component\Console\Command\Command;
27
use Symfony\Component\Console\Input\InputInterface;
28
use Symfony\Component\Console\Output\OutputInterface;
29
30
/**
31
 * Class SendEventReminders
32
 *
33
 * @package OCA\DAV\Command
34
 */
35
class SendEventReminders extends Command {
36
37
	/** @var ReminderService */
38
	protected $reminderService;
39
40
	/** @var IConfig */
41
	protected $config;
42
43
	/**
44
	 * @param ReminderService $reminderService
45
	 * @param IConfig $config
46
	 */
47
	public function __construct(ReminderService $reminderService,
48
								IConfig $config) {
49
		parent::__construct();
50
		$this->reminderService = $reminderService;
51
		$this->config = $config;
52
	}
53
54
	/**
55
	 * @inheritDoc
56
	 */
57
	protected function configure():void {
58
		$this
59
			->setName('dav:send-event-reminders')
60
			->setDescription('Sends event reminders');
61
	}
62
63
	/**
64
	 * @param InputInterface $input
65
	 * @param OutputInterface $output
66
	 */
67
	protected function execute(InputInterface $input, OutputInterface $output):void {
68
		if ($this->config->getAppValue('dav', 'sendEventReminders', 'yes') !== 'yes') {
69
			$output->writeln('<error>Sending event reminders disabled!</error>');
70
			$output->writeln('<info>Please run "php occ config:app:set dav sendEventReminders --value yes"');
71
			return;
72
		}
73
74
		if ($this->config->getAppValue('dav', 'sendEventRemindersMode', 'backgroundjob') !== 'occ') {
75
			$output->writeln('<error>Sending event reminders mode set to background-job!</error>');
76
			$output->writeln('<info>Please run "php occ config:app:set dav sendEventRemindersMode --value occ"');
77
			return;
78
		}
79
80
		$this->reminderService->processReminders();
81
	}
82
}
83