1
|
|
|
<?php |
2
|
|
|
namespace SeleniumSetup\Controller; |
3
|
|
|
|
4
|
|
|
use SeleniumSetup\Config\Config; |
5
|
|
|
use SeleniumSetup\Config\ConfigFactory; |
6
|
|
|
use SeleniumSetup\Environment; |
7
|
|
|
use SeleniumSetup\Locker\Locker; |
8
|
|
|
use SeleniumSetup\Service\StopServerService; |
9
|
|
|
use Symfony\Component\Console\Command\Command; |
10
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
11
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
12
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
13
|
|
|
|
14
|
|
|
class StopServer extends Command |
15
|
|
|
{ |
16
|
|
|
const CLI_COMMAND = 'stop'; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Configure the command options. |
20
|
|
|
* |
21
|
|
|
* @return void |
22
|
|
|
*/ |
23
|
|
|
protected function configure() |
24
|
|
|
{ |
25
|
|
|
$defaultName = basename(Config::DEFAULT_CONFIGURATION_FILENAME, '.json'); |
26
|
|
|
|
27
|
|
|
$this |
28
|
|
|
->setName(self::CLI_COMMAND) |
29
|
|
|
->setDescription('Stop Selenium Server.') |
30
|
|
|
->addArgument('name', InputArgument::OPTIONAL, 'The name of the server.', $defaultName); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Execute the command. |
35
|
|
|
* |
36
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
37
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
38
|
|
|
* @return void |
39
|
|
|
*/ |
40
|
|
|
public function execute(InputInterface $input, OutputInterface $output) |
41
|
|
|
{ |
42
|
|
|
$locker = new Locker(); |
43
|
|
|
$locker->openLockFile(); |
44
|
|
|
$serverItem = $locker->getServer($input->getArgument('name')); |
45
|
|
|
|
46
|
|
|
// Prepare. |
47
|
|
|
$config = ConfigFactory::createFromConfigFile($serverItem->getConfigFilePath()); |
48
|
|
|
$env = new Environment($config, $input, $output); |
49
|
|
|
|
50
|
|
|
$handler = new StopServerService($config, $env, $input, $output); |
51
|
|
|
$handler->handle(); |
52
|
|
|
} |
53
|
|
|
} |