Skip to content

Commit

Permalink
Added $prefix generation in core.php for cake bake shell
Browse files Browse the repository at this point in the history
  • Loading branch information
tigrang authored and markstory committed Aug 25, 2012
1 parent d66d37c commit 8e818c8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/Cake/Console/Command/Task/ProjectTask.php
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit 8e818c8

Please sign in to comment.