Skip to content
Permalink
Browse files

Added `$prefix` generation in `core.php` for `cake bake` shell

  • Loading branch information...
tigrang authored and markstory committed Jan 23, 2012
1 parent d66d37c commit 8e818c89b69799680ca2a11e5d619ef1641b3b6d
Showing with 27 additions and 0 deletions.
  1. +27 −0 lib/Cake/Console/Command/Task/ProjectTask.php
@@ -92,6 +92,13 @@ public function execute() {
$success = false;
}
if ($this->cachePrefix($path)) {
$this->out(__d('cake_console', ' * Cache prefix set'));
} else {
$this->err(__d('cake_console', 'The cache prefix was <error>NOT</error> set'));
$success = false;
}
if ($this->consolePath($path) === true) {
$this->out(__d('cake_console', ' * app/Console/cake.php path set.'));
} else {
@@ -284,6 +291,26 @@ public function securityCipherSeed($path) {
return false;
}
/**
* Writes cache prefix using app's name
*
* @param string $dir Path to project
* @return boolean Success
*/
public function cachePrefix($dir) {
$app = basename($dir);
$File = new File($dir . 'Config' . DS . 'core.php');
$contents = $File->read();
if (preg_match('/(\$prefix = \'myapp_\';)/', $contents, $match)) {
$result = str_replace($match[0], '$prefix = \'' . $app . '_\';', $contents);
if ($File->write($result)) {
return true;
}
return false;
}
return false;
}
/**
* Generates and writes CAKE_CORE_INCLUDE_PATH
*

0 comments on commit 8e818c8

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