DisableBackend::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace OCA\Chat\Command;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use OCA\Chat\BackendNotFoundException;
10
use \OCA\CHat\IBackendManager;
11
12
13
class DisableBackend extends Command {
14
15
	/**
16
	 * @var \OCA\Chat\IBackendManager
17
	 */
18
	private $backendManager;
19
20
	public function __construct(IBackendManager $backendManager){
21
		$this->backendManager = $backendManager;
22
		parent::__construct();
23
	}
24
	
25
	public function configure(){
26
		$this->setName('chat-backend:disable')
27
			->setDescription('Disable a specific backend')
28
			->addArgument(
29
				'backend',
30
				InputArgument::REQUIRED,
31
				'The id of the backend which you want to disable'
32
				)
33
			;
34
	}
35
36
	public function execute(InputInterface $input, OutputInterface $output){
37
		$backend = $input->getArgument('backend');
38
		try {
39
			$this->backendManager->disableBackend($backend);
40
			$output->writeln("Chat Backend '". $backend . "' is disabled.");
41
		} Catch (BackendNotFoundException $e){
42
			$output->writeln("<error>Chat Backend does not exists.</error>");
43
		}
44
	}
45
	
46
}