Skip to content

Commit

Permalink
Fixed issue when updating namespaces and theme name
Browse files Browse the repository at this point in the history
  • Loading branch information
Alecaddd committed Apr 13, 2018
1 parent fb238fd commit 5705862
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ public function execute(InputInterface $input, OutputInterface $output)

$helper = $this->getHelper("question");

$question = new Question("Name of your theme? <info>(Awps)</info> ", "Awps");
$question = new Question("Name of your theme? <info>(Awps)</info> ", null);
$themeName = $helper->ask($input, $output, $question);

$question = new Question("PHP Namespace of your theme? <info>(awps)</info> ", "awps");
$question = new Question("PHP Namespace of your theme? <info>(Awps)</info> ", null);
$namespace = $helper->ask($input, $output, $question);

$question = new Question("Description? <info>(Alecaddd WordPress Starter theme)</info> ", "Alecaddd WordPress Starter theme");
$question = new Question("Description? <info>(Alecaddd WordPress Starter theme)</info> ", null);
$description = $helper->ask($input, $output, $question);

$output->writeln('<info>Downloading Package..</info>');
Expand Down Expand Up @@ -206,19 +206,25 @@ private function renameAllTheThings($directory, OutputInterface $output, $themeN
return $this;
}

$output->writeln('<info>Updating namespaces..</info>');

$file_info = array();

$this->recursiveScanFiles($directory, $file_info);

foreach ($file_info as $file) {
$str = file_get_contents($file);

if (! is_null($themeName)) {
$str = str_replace("Awps", $themeName, $str);
}

if (! is_null($namespace)) {
$str = str_replace("awps", $namespace, $str);
$str = str_replace("use Awps", "use " . $namespace, $str);
$str = str_replace("namespace Awps", "namespace " . $namespace, $str);
$str = str_replace("Awps\\", $namespace . "\\", $str);
$str = str_replace("Awps\Init", $namespace . "\Init", $str);
}

if (! is_null($themeName)) {
$str = str_replace("Awps", $themeName, $str);
}

if (! is_null($description)) {
Expand Down

0 comments on commit 5705862

Please sign in to comment.