Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions src/Console/Command/ModuleCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public function setSkeletonModuleDir($moduleDir)

/**
* @param string $moduleDir
*
* @return void
*/
public function setTargetModuleDir($moduleDir)
{
Expand All @@ -155,13 +157,16 @@ public function setTargetModuleDir($moduleDir)

/**
* @param array $tplEngines
*
* @return void
*/
public function setEnabledTemplatingEngines(array $tplEngines)
{
$this->configEnabledTemplatingEngines = $tplEngines;
}

/**
* @return void
*/
protected function configure()
{
Expand Down Expand Up @@ -208,7 +213,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->processRoutingFiles($tokenizedFiles, $tokens);
$output->writeln(sprintf("Router: <info>%s</info>", $this->routingEngine));
} else {
$tokens['ROUTING_TRAIT'] = '';
$tokens['[ROUTING_TRAIT]'] = '';
}

// replace tokens from specified tokenizable files
Expand Down Expand Up @@ -320,8 +325,10 @@ protected function askQuestions(InputInterface $input, OutputInterface $output)
$this->chooseTemplatingEngine($input, $output);
}

if($this->askForRouting($input, $output)) {
$this->chooseRouter($input, $output);
if($this->askForContoller($input, $output)) {
if($this->askForRouting($input, $output)) {
return $this->chooseRouter($input, $output);
}
}
}

Expand Down Expand Up @@ -416,7 +423,7 @@ private function askForTemplating(InputInterface $input, OutputInterface $output
private function askForRouting(InputInterface $input, OutputInterface $output)
{
$questionHelper = $this->getHelper('question');
$question = new ConfirmationQuestion("Do you need routing? (yes/no):\n", false);
$question = new ConfirmationQuestion("Which router do you want? (yes/no):\n", false);

return $questionHelper->ask($input, $output, $question);
}
Expand All @@ -439,6 +446,12 @@ private function chooseTemplatingEngine($input, $output)
}
}

/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return void
*/
private function chooseRouter(InputInterface $input, OutputInterface $output)
{
$routingQuestion = new ChoiceQuestion('Choose your routing engine:',
Expand All @@ -460,13 +473,21 @@ private function chooseRouter(InputInterface $input, OutputInterface $output)
$this->routingEngine = $chosenRouter;
}

/**
* @param $tplEngine
*
* @return void
*/
private function getTemplatingFilesFromEngine($tplEngine)
{
if(!isset($this->tplEngineFilesMap[$tplEngine])) {
throw new \InvalidArgumentException('Invalid templating engine specified for map files: ' . $tplEngine);
}
}

/**
* @return void
*/
private function processTemplatingFiles()
{
$tplFiles = $this->getTemplatingFilesFromEngine($this->tplEngine);
Expand Down Expand Up @@ -495,6 +516,8 @@ private function processTemplatingFiles()

/**
* @throws \Exception
*
* @return void
*/
private function processRoutingFiles($tokenizedFiles, $tokens)
{
Expand Down Expand Up @@ -543,6 +566,9 @@ private function processRoutingFiles($tokenizedFiles, $tokens)
}
}

/**
* @return array
*/
protected function getTokenizedCoreFiles()
{
$files = [];
Expand All @@ -552,6 +578,11 @@ protected function getTokenizedCoreFiles()
return $files;
}

/**
* @param $routingEngine
* @return array
* @throws \Exception
*/
private function getRoutingTokenMap($routingEngine) {

// if(!isset($this->routingEngineTokenMap[$routingEngine])) {
Expand Down