Skip to content
Permalink
Browse files

Add _deleteEmptyFile method to BakeTask

  • Loading branch information...
bcrowe committed Sep 23, 2014
1 parent f845c10 commit 4dc32ee49356e6bc6b120ff52c59bdf93ebd661c
Showing with 18 additions and 17 deletions.
  1. +15 −0 src/Shell/Task/BakeTask.php
  2. +2 −11 src/Shell/Task/ModelTask.php
  3. +1 −6 src/Shell/Task/SimpleBakeTask.php
@@ -18,6 +18,7 @@
use Cake\Console\Shell;
use Cake\Core\Configure;
use Cake\Core\ConventionsTrait;
use Cake\Filesystem\File;
/**
* Base class for Bake Tasks.
@@ -157,6 +158,20 @@ protected function _getName($name) {
return $name;
}
/**
* Delete empty file in a given path
*
* @param string $path Path to folder which contains 'empty' file.
* @return void
*/
protected function _deleteEmptyFile($path) {
$File = new File($path);
if ($File->exists()) {
$File->delete();
$this->out(sprintf('<success>Deleted</success> `%s`', $path), 1, Shell::QUIET);
}
}
/**
* Get the option parser for this task.
*
@@ -17,7 +17,6 @@
use Cake\Console\Shell;
use Cake\Core\Configure;
use Cake\Datasource\ConnectionManager;
use Cake\Filesystem\File;
use Cake\ORM\Table;
use Cake\ORM\TableRegistry;
use Cake\Utility\Inflector;
@@ -604,11 +603,7 @@ public function bakeEntity($model, array $data = []) {
$this->out("\n" . sprintf('Baking entity class for %s...', $name), 1, Shell::QUIET);
$this->createFile($filename, $out);
$emptyFile = $path . 'Entity' . DS . 'empty';
$File = new File($emptyFile);
if ($File->exists()) {
$File->delete();
$this->out(sprintf('<success>Deleted</success> `%s`', $emptyFile), 1, Shell::QUIET);
}
$this->_deleteEmptyFile($emptyFile);
return $out;
}
@@ -653,11 +648,7 @@ public function bakeTable($model, array $data = []) {
$this->out("\n" . sprintf('Baking table class for %s...', $name), 1, Shell::QUIET);
$this->createFile($filename, $out);
$emptyFile = $path . 'Table' . DS . 'empty';
$File = new File($emptyFile);
if ($File->exists()) {
$File->delete();
$this->out(sprintf('<success>Deleted</success> `%s`', $emptyFile), 1, Shell::QUIET);
}
$this->_deleteEmptyFile($emptyFile);
return $out;
}
@@ -18,7 +18,6 @@
use Cake\Shell\Task\BakeTask;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Filesystem\File;
use Cake\Utility\Inflector;
/**
@@ -99,11 +98,7 @@ public function bake($name) {
$filename = $this->getPath() . $this->fileName($name);
$this->createFile($filename, $contents);
$emptyFile = $this->getPath() . 'empty';
$File = new File($emptyFile);
if ($File->exists()) {
$File->delete();
$this->out(sprintf('<success>Deleted</success> `%s`', $emptyFile), 1, Shell::QUIET);
}
$this->_deleteEmptyFile($emptyFile);
return $contents;
}

0 comments on commit 4dc32ee

Please sign in to comment.
You can’t perform that action at this time.