blob: e9946ad4cc701b7b91c384aeb47cd62d9997daf9 (
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
/**
* SPDX-FileCopyrightText: 2015 Christian Kampka <christian@kampka.net>
* SPDX-License-Identifier: MIT
*/
namespace OC\Core\Command\Background;
use OCP\IConfig;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
* An abstract base class for configuring the background job mode
* from the command line interface.
* Subclasses will override the getMode() function to specify the mode to configure.
*/
abstract class Base extends Command {
abstract protected function getMode();
public function __construct(
protected IConfig $config,
) {
parent::__construct();
}
protected function configure(): void {
$mode = $this->getMode();
$this
->setName("background:$mode")
->setDescription("Use $mode to run background jobs");
}
/**
* Executing this command will set the background job mode for owncloud.
* The mode to set is specified by the concrete sub class by implementing the
* getMode() function.
*
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
$mode = $this->getMode();
$this->config->setAppValue('core', 'backgroundjobs_mode', $mode);
$output->writeln("Set mode for background jobs to '$mode'");
return 0;
}
}
|