|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace N98\Magento\Command\Developer\Module\Create\SubCommand; |
|
4
|
|
|
|
|
5
|
|
|
use N98\Magento\Command\SubCommand\AbstractSubCommand; |
|
6
|
|
|
|
|
7
|
|
|
class CreateModuleFolders extends AbstractSubCommand |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @return bool |
|
11
|
|
|
*/ |
|
12
|
|
|
public function execute() |
|
13
|
|
|
{ |
|
14
|
|
|
$config = $this->config; |
|
15
|
|
|
|
|
16
|
|
|
if ($config->getBool('isModmanMode')) { |
|
17
|
|
|
$modManDir = sprintf('%s_%s/src', $config->getString('vendorNamespace'), $config->getString('moduleName')); |
|
18
|
|
|
if (file_exists($modManDir)) { |
|
19
|
|
|
throw new \RuntimeException('Module already exists. Stop.'); |
|
20
|
|
|
} |
|
21
|
|
|
mkdir($modManDir, 0777, true); |
|
22
|
|
|
$config->setString('magentoRootFolder', './' . $modManDir); |
|
|
|
|
|
|
23
|
|
|
$config->setString('modmanRootFolder', './' . substr($modManDir, 0, -4)); |
|
|
|
|
|
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
$moduleDir = $config->getString('magentoRootFolder') |
|
27
|
|
|
. '/app/code' |
|
28
|
|
|
. '/' . $config->getString('vendorNamespace') |
|
29
|
|
|
. '/' . $config->getString('moduleName'); |
|
30
|
|
|
if (file_exists($moduleDir)) { |
|
31
|
|
|
throw new \RuntimeException('Module already exists. Stop.'); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
$config->setString('moduleDirectory', $moduleDir); |
|
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
mkdir($moduleDir, 0777, true); |
|
37
|
|
|
$this->output->writeln('<info>Created directory: <comment>' . $moduleDir . '<comment></info>'); |
|
38
|
|
|
|
|
39
|
|
|
// Add etc folder |
|
40
|
|
|
mkdir($moduleDir . '/etc'); |
|
41
|
|
|
$this->output->writeln('<info>Created directory: <comment>' . $moduleDir . '/etc<comment></info>'); |
|
42
|
|
|
|
|
43
|
|
|
// Add blocks folder |
|
44
|
|
View Code Duplication |
if ($config->getBool('shouldAddBlocks')) { |
|
|
|
|
|
|
45
|
|
|
mkdir($moduleDir . '/Block'); |
|
46
|
|
|
$this->output->writeln('<info>Created directory: <comment>' . $moduleDir . '/Block' . '<comment></info>'); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
// Add helpers folder |
|
50
|
|
View Code Duplication |
if ($config->getBool('shouldAddHelpers')) { |
|
|
|
|
|
|
51
|
|
|
mkdir($moduleDir . '/Helper'); |
|
52
|
|
|
$this->output->writeln('<info>Created directory: <comment>' . $moduleDir . '/Helper' . '<comment></info>'); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
// Add models folder |
|
56
|
|
View Code Duplication |
if ($config->getBool('shouldAddModels')) { |
|
|
|
|
|
|
57
|
|
|
mkdir($moduleDir . '/Model'); |
|
58
|
|
|
$this->output->writeln('<info>Created directory: <comment>' . $moduleDir . '/Model' . '<comment></info>'); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
// Create SQL and Data folder |
|
62
|
|
|
if ($config->getBool('shouldAddSetup')) { |
|
63
|
|
|
$setupFolder = $moduleDir . '/Setup/'; |
|
64
|
|
|
mkdir($setupFolder, 0777, true); |
|
65
|
|
|
$this->output->writeln('<info>Created directory: <comment>' . $setupFolder . '<comment></info>'); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
return true; |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: