Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Fix for #125 controller creation when directory is missing #126

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion src/ZFTool/Controller/CreateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ public function controllerAction()
}

$ucName = ucfirst($name);
$ctrlPath = $path . '/module/' . $module . '/src/' . $module . '/Controller/' . $ucName.'Controller.php';
$ctrlDir = $path . '/module/' . $module . '/src/' . $module . '/Controller/';
$ctrlPath = $ctrlDir . $ucName.'Controller.php';
$controller = $ucName . 'Controller';

$code = new Generator\ClassGenerator();
Expand Down Expand Up @@ -151,6 +152,10 @@ public function controllerAction()
$phtml = true;
}

if (!file_exists($ctrlDir)) {
mkdir($ctrlDir, 0777, true);
}

if (file_put_contents($ctrlPath, $file->generate()) && $phtml == true) {
$console->writeLine("The controller $name has been created in module $module.", Color::GREEN);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ public function testDataDump()
' )' . PHP_EOL .
' ---------------------------------' . PHP_EOL, ob_get_clean()
);
ob_start();
}

public function testSummaryAllSuccessful()
Expand Down