1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: nicolas |
5
|
|
|
* Date: 05/02/17 |
6
|
|
|
* Time: 14:32 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Devgiants\Command; |
10
|
|
|
|
11
|
|
|
use Buzz\Message\Request; |
|
|
|
|
12
|
|
|
use Devgiants\Configuration\ConfigurationManager; |
13
|
|
|
use Devgiants\Configuration\ApplicationConfiguration as AppConf; |
14
|
|
|
use Devgiants\Model\ApplicationCommand; |
15
|
|
|
use Pimple\Container; |
|
|
|
|
16
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
|
|
|
17
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
|
|
|
18
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
|
|
|
19
|
|
|
|
20
|
|
|
class WifiStatusCommand extends ApplicationCommand { |
21
|
|
|
|
22
|
|
|
const STATUS = 'status'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* WifiStatusCommand constructor. |
26
|
|
|
* |
27
|
|
|
* @param null|string $name |
28
|
|
|
* @param Container $container |
29
|
|
|
*/ |
30
|
|
|
public function __construct( $name, Container $container ) { |
31
|
|
|
parent::__construct( $name, $container ); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @inheritdoc |
36
|
|
|
*/ |
37
|
|
|
protected function configure() { |
38
|
|
|
$this |
39
|
|
|
->setName( 'wifi:status' ) |
40
|
|
|
->setDescription( 'Get wifi status (1 = ON, 0 = OFF)' ) |
41
|
|
|
->addArgument( static::STATUS, InputArgument::OPTIONAL, "Get wifi status" ) |
42
|
|
|
->setHelp( "This command allows you to get wifi status" ); |
43
|
|
|
|
44
|
|
|
parent::configure(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @inheritdoc |
49
|
|
|
*/ |
50
|
|
|
protected function execute( InputInterface $input, OutputInterface $output ) { |
51
|
|
|
|
52
|
|
|
$ymlFile = $this->getConfigurationFile( $input ); |
53
|
|
|
|
54
|
|
|
if ( $ymlFile !== NULL && is_file( $ymlFile ) ) { |
55
|
|
|
|
56
|
|
|
// Structures check and configuration loading |
57
|
|
|
$configurationManager = new ConfigurationManager( $ymlFile ); |
58
|
|
|
$configuration = $configurationManager->load(); |
59
|
|
|
|
60
|
|
|
// Get status |
61
|
|
|
if ( $input->hasArgument( static::STATUS ) ) { |
62
|
|
|
$response = $this->tools->createRequest( |
63
|
|
|
Request::METHOD_POST, |
64
|
|
|
"{$configuration[ AppConf::HOST[ AppConf::NODE_NAME ] ]}/ws", |
65
|
|
|
[ |
66
|
|
|
"service" => "NMC.Wifi", |
67
|
|
|
"method" => "get", |
68
|
|
|
"parameters" => [], |
69
|
|
|
] |
70
|
|
|
); |
71
|
|
|
|
72
|
|
|
$json = json_decode( $response->getContent() ); |
73
|
|
|
|
74
|
|
|
if ( isset( $json->result->status ) ) { |
75
|
|
|
$output->write( $json->result->status->Status ? 1 : 0 ); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
// Handle post command stuff |
80
|
|
|
parent::execute( $input, $output ); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
} |
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