1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the O2System PHP Framework package. |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
6
|
|
|
* file that was distributed with this source code. |
7
|
|
|
* |
8
|
|
|
* @author Steeve Andrian Salim |
9
|
|
|
* @copyright Copyright (c) Steeve Andrian Salim |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
// ------------------------------------------------------------------------ |
13
|
|
|
|
14
|
|
|
namespace O2System\Reactor\Cli\Commanders\Make; |
15
|
|
|
|
16
|
|
|
// ------------------------------------------------------------------------ |
17
|
|
|
|
18
|
|
|
use O2System\Reactor\Cli\Commanders\Make; |
19
|
|
|
use O2System\Kernel\Cli\Writers\Format; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Class Config |
23
|
|
|
* |
24
|
|
|
* @package O2System\Reactor\Cli\Commanders\Make |
25
|
|
|
*/ |
26
|
|
|
class Config extends Make |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Config::$commandDescription |
30
|
|
|
* |
31
|
|
|
* Command description. |
32
|
|
|
* |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
protected $commandDescription = 'CLI_MAKE_CONFIG_DESC'; |
36
|
|
|
|
37
|
|
|
public function execute() |
38
|
|
|
{ |
39
|
|
|
parent::execute(); |
40
|
|
|
|
41
|
|
|
if (empty($this->optionFilename)) { |
42
|
|
|
output()->write( |
|
|
|
|
43
|
|
|
(new Format()) |
44
|
|
|
->setContextualClass(Format::DANGER) |
45
|
|
|
->setString(language()->getLine('CLI_MAKE_CONFIG_E_FILENAME')) |
46
|
|
|
->setNewLinesAfter(1) |
47
|
|
|
); |
48
|
|
|
|
49
|
|
|
exit(EXIT_ERROR); |
|
|
|
|
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
if (strpos($this->optionPath, 'Config') === false) { |
53
|
|
|
$filePath = $this->optionPath . 'Config' . DIRECTORY_SEPARATOR . $this->optionFilename; |
54
|
|
|
} else { |
55
|
|
|
$filePath = $this->optionPath . $this->optionFilename; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
if ( ! is_dir(dirname($filePath))) { |
59
|
|
|
mkdir(dirname($filePath), 777, true); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
if (is_file($filePath)) { |
63
|
|
|
output()->write( |
64
|
|
|
(new Format()) |
65
|
|
|
->setContextualClass(Format::DANGER) |
66
|
|
|
->setString(language()->getLine('CLI_MAKE_CONFIG_E_EXISTS', [$filePath])) |
67
|
|
|
->setNewLinesAfter(1) |
68
|
|
|
); |
69
|
|
|
|
70
|
|
|
exit(EXIT_ERROR); |
|
|
|
|
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
$vars[ 'CREATE_DATETIME' ] = date('d/m/Y H:m'); |
|
|
|
|
74
|
|
|
$vars[ 'CONFIG' ] = '$' . camelcase(pathinfo($filePath, PATHINFO_FILENAME)); |
75
|
|
|
$vars[ 'FILEPATH' ] = $filePath; |
76
|
|
|
|
77
|
|
|
$phpTemplate = <<<PHPTEMPLATE |
78
|
|
|
<?php |
79
|
|
|
/** |
80
|
|
|
* Created by O2System Reactor File Generator. |
81
|
|
|
* DateTime: CREATE_DATETIME |
82
|
|
|
*/ |
83
|
|
|
|
84
|
|
|
// ------------------------------------------------------------------------ |
85
|
|
|
|
86
|
|
|
CONFIG = []; |
87
|
|
|
PHPTEMPLATE; |
88
|
|
|
|
89
|
|
|
$fileContent = str_replace(array_keys($vars), array_values($vars), $phpTemplate); |
90
|
|
|
file_put_contents($filePath, $fileContent); |
91
|
|
|
|
92
|
|
|
if (is_file($filePath)) { |
93
|
|
|
output()->write( |
94
|
|
|
(new Format()) |
95
|
|
|
->setContextualClass(Format::SUCCESS) |
96
|
|
|
->setString(language()->getLine('CLI_MAKE_CONFIG_S_MAKE', [$filePath])) |
97
|
|
|
->setNewLinesAfter(1) |
98
|
|
|
); |
99
|
|
|
|
100
|
|
|
exit(EXIT_SUCCESS); |
|
|
|
|
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
} |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.