Skip to content

Commit 9ef8254

Browse files
committed
Remove exec
1 parent 65510fe commit 9ef8254

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

Console/Command/ThemeCreateCommand.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44

55
namespace Yireo\ThemeCommands\Console\Command;
66

7+
use Magento\Framework\Shell;
78
use Symfony\Component\Console\Input\InputOption;
89
use Magento\Framework\Component\ComponentRegistrar;
910
use Magento\Framework\Filesystem\DirectoryList;
1011
use Symfony\Component\Console\Command\Command;
11-
use Symfony\Component\Console\Input\InputArgument;
1212
use Symfony\Component\Console\Input\InputInterface;
1313
use Symfony\Component\Console\Output\OutputInterface;
1414
use Throwable;
15-
1615
class ThemeCreateCommand extends Command
1716
{
1817
public function __construct(
1918
private DirectoryList $directoryList,
2019
private ComponentRegistrar $componentRegistrar,
20+
private Shell $shell,
2121
private string $themeSkeletonFolder = '',
2222
string $name = null
2323
) {
2424
parent::__construct($name);
2525
}
26-
26+
2727
/**
2828
* Initialization of the command.
2929
*/
@@ -37,7 +37,7 @@ protected function configure(): void
3737
$this->addOption('application', null, InputOption::VALUE_OPTIONAL, 'Application');
3838
parent::configure();
3939
}
40-
40+
4141
/**
4242
* CLI command description.
4343
*
@@ -52,15 +52,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5252
$themeName = trim($input->getOption('theme'));
5353
$parentThemeName = trim($input->getOption('parent'));
5454
$application = trim($input->getOption('application'));
55-
55+
5656
$themeFolder = $this->getThemeFolder($themeName, $application);
57-
exec('mkdir -p '.$themeFolder);
58-
57+
$this->shell->execute('mkdir -p '.$themeFolder);
58+
5959
$this->generateRegistrationFile($themeFolder, $application . '/' . $themeName);
6060
$this->generateThemeXmlFile($themeFolder, $themeName, $parentThemeName);
6161
return Command::SUCCESS;
6262
}
63-
63+
6464
/**
6565
* @param string $themeFolder
6666
* @param string $componentName
@@ -73,7 +73,7 @@ private function generateRegistrationFile(string $themeFolder, string $component
7373
$contents = str_replace('{{ COMPONENT_NAME }}', $componentName, $contents);
7474
file_put_contents($themeFolder . '/registration.php', $contents);
7575
}
76-
76+
7777
/**
7878
* @param string $themeFolder
7979
* @param string $componentName
@@ -87,7 +87,7 @@ private function generateThemeXmlFile(string $themeFolder, string $themeName, st
8787
$contents = str_replace('{{ PARENT_THEME_NAME }}', $parentThemeName, $contents);
8888
file_put_contents($themeFolder . '/theme.xml', $contents);
8989
}
90-
90+
9191
/**
9292
* @param string $themeName
9393
* @param string $application
@@ -98,10 +98,10 @@ private function getThemeFolder(string $themeName, string $application): string
9898
if (empty($application)) {
9999
$application = 'frontend';
100100
}
101-
101+
102102
return $this->directoryList->getRoot() . '/app/design/' . $application . '/' . $themeName;
103103
}
104-
104+
105105
/**
106106
* @return string
107107
*/
@@ -112,12 +112,12 @@ private function getThemeSkeletonFolder(): string
112112
if (empty($this->themeSkeletonFolder)) {
113113
return $defaultThemeSkeletonFolder;
114114
}
115-
115+
116116
$themeSkeletonFolder = $this->directoryList->getRoot() . '/' . $this->themeSkeletonFolder;
117117
if (!is_dir($this->themeSkeletonFolder)) {
118118
return $defaultThemeSkeletonFolder;
119119
}
120-
120+
121121
return $themeSkeletonFolder;
122122
}
123123
}

0 commit comments

Comments
 (0)