EnableBackend::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
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 EnableBackend extends Command {
14
15
	/**
16
	 * @var \OCA\Chat\IBackendManager
17
	 */
18
	private $backendManager;
19
20
21
	public function __construct(IBackendManager $backendManager){
22
		$this->backendManager = $backendManager;
23
		parent::__construct();
24
	}
25
	
26
	public function configure(){
27
		$this->setName('chat-backend:enable')
28
			->setDescription('Enable a specific backend')
29
			->addArgument(
30
				'backend',
31
				InputArgument::REQUIRED,
32
				'The id of the backend which you want to enable'
33
				)
34
			;
35
	}
36
37
	public function execute(InputInterface $input, OutputInterface $output){
38
		$backend = $input->getArgument('backend');
39
		try {
40
			$this->backendManager->enableBackend($backend);
41
			$output->writeln("Chat Backend '". $backend . "' is enabled.");
42
		} Catch (BackendNotFoundException $e) {
43
			$output->writeln("<error>Chat Backend does not exists.</error>");
44
		}
45
	}
46
	
47
}