|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: nicolas |
|
5
|
|
|
* Date: 22/12/17 |
|
6
|
|
|
* Time: 14:34 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Devgiants\Model; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
use Devgiants\Exception\MissingConfigurationFileException; |
|
13
|
|
|
use Devgiants\Service\LiveboxTools; |
|
14
|
|
|
use Monolog\Logger; |
|
|
|
|
|
|
15
|
|
|
use Pimple\Container; |
|
|
|
|
|
|
16
|
|
|
use Symfony\Component\Console\Command\Command; |
|
|
|
|
|
|
17
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
|
|
|
|
|
18
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
|
|
|
|
|
19
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
|
|
|
|
|
20
|
|
|
use Symfony\Component\Finder\Finder; |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
abstract class ApplicationCommand extends Command { |
|
23
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
const FILE_OPTION = 'file'; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var Container |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $container; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var Logger |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $log; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var LiveboxTools |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $tools; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var string $host |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $host; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* ApplicationCommand constructor. |
|
49
|
|
|
* |
|
50
|
|
|
* @param null|string $name |
|
51
|
|
|
* @param Container $container |
|
52
|
|
|
*/ |
|
53
|
|
|
public function __construct( $name, Container $container ) { |
|
54
|
|
|
$this->container = $container; |
|
55
|
|
|
parent::__construct( $name ); |
|
56
|
|
|
|
|
57
|
|
|
// Initiates logging |
|
58
|
|
|
$this->log = $this->container['main_logger']; |
|
59
|
|
|
if ( ! $this->log instanceof Logger ) { |
|
60
|
|
|
throw new \InvalidArgumentException( "Container main_logger entry must be Logger type" ); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
$this->tools = $this->container['tools']; |
|
64
|
|
|
if ( ! $this->tools instanceof LiveboxTools ) { |
|
65
|
|
|
throw new \InvalidArgumentException( "Container tools entry must be LiveboxTools type" ); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @inheritdoc |
|
71
|
|
|
*/ |
|
72
|
|
|
protected function configure() { |
|
73
|
|
|
$this |
|
74
|
|
|
->addOption( self::FILE_OPTION, "f", InputOption::VALUE_OPTIONAL, "The YML configuration file" ); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @param InputInterface $input |
|
79
|
|
|
* |
|
80
|
|
|
* @return string |
|
81
|
|
|
* @throws MissingConfigurationFileException |
|
82
|
|
|
*/ |
|
83
|
|
|
public function getConfigurationFile( InputInterface $input ) { |
|
84
|
|
|
$ymlFile = $input->getOption( self::FILE_OPTION ); |
|
85
|
|
|
if ( $ymlFile === NULL ) { |
|
86
|
|
|
$finder = new Finder(); |
|
87
|
|
|
$finder |
|
88
|
|
|
->in( $this->container['app_dir'] ) |
|
89
|
|
|
->files() |
|
90
|
|
|
->name( '*.yml' ); |
|
91
|
|
|
|
|
92
|
|
|
if ( $finder->count() === 1 ) { |
|
93
|
|
|
foreach ( $finder as $file ) { |
|
94
|
|
|
$ymlFile = $file->getRealPath(); |
|
95
|
|
|
} |
|
96
|
|
|
} else { |
|
97
|
|
|
throw new MissingConfigurationFileException(); |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
return $ymlFile; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @inheritdoc |
|
106
|
|
|
*/ |
|
107
|
|
|
protected function execute( InputInterface $input, OutputInterface $output ) { |
|
108
|
|
|
$this->tools->logout( '192.168.1.1' ); |
|
109
|
|
|
} |
|
110
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths