1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of phpDocumentor. |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
6
|
|
|
* file that was distributed with this source code. |
7
|
|
|
* |
8
|
|
|
* @copyright 2010-2015 Mike van Riel<[email protected]> |
9
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
10
|
|
|
* @link http://phpdoc.org |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace phpDocumentor\DomainModel; |
14
|
|
|
|
15
|
|
|
use phpDocumentor\Application\Configuration\ConfigurationFactory; |
16
|
|
|
use phpDocumentor\Application\Configuration\Factory\CommandlineOptionsMiddleware; |
17
|
|
|
use phpDocumentor\Configuration; |
18
|
|
|
use phpDocumentor\DomainModel\MergeConfigurationWithCommandLineOptions; |
19
|
|
|
use phpDocumentor\DomainModel\Uri; |
20
|
|
|
|
21
|
|
|
final class MergeConfigurationWithCommandLineOptionsHandler |
22
|
|
|
{ |
23
|
|
|
/** @var ConfigurationFactory */ |
24
|
|
|
private $configurationFactory; |
25
|
|
|
|
26
|
|
|
/** @var CommandlineOptionsMiddleware */ |
27
|
|
|
private $commandlineOptionsMiddleware; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* MergeConfigurationWithCommandLineOptionsHandler constructor. |
31
|
|
|
* |
32
|
|
|
* @param ConfigurationFactory $configurationFactory |
33
|
|
|
* @param CommandlineOptionsMiddleware $commandlineOptionsMiddleware |
34
|
|
|
*/ |
35
|
|
|
public function __construct( |
36
|
|
|
ConfigurationFactory $configurationFactory, |
37
|
|
|
CommandlineOptionsMiddleware $commandlineOptionsMiddleware |
|
|
|
|
38
|
|
|
) { |
39
|
|
|
$this->configurationFactory = $configurationFactory; |
40
|
|
|
$this->commandlineOptionsMiddleware = $commandlineOptionsMiddleware; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function __invoke(MergeConfigurationWithCommandLineOptions $command) |
44
|
|
|
{ |
45
|
|
|
if (isset($command->getOptions()['config']) |
46
|
|
|
&& $command->getOptions()['config'] |
47
|
|
|
&& realpath($command->getOptions()['config']) |
48
|
|
|
) { |
49
|
|
|
$uri = new Uri(realpath($command->getOptions()['config'])); |
50
|
|
|
$this->configurationFactory->replaceLocation($uri); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$this->commandlineOptionsMiddleware->provideOptions($command->getOptions()); |
54
|
|
|
$this->configurationFactory->clearCache(); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.