Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 6ee3c1cb2491386f19cb1b2945160f6da1497bae 1 parent 4867902
@tigrang authored
Showing with 27 additions and 0 deletions.
  1. +27 −0 lib/Cake/Console/Command/Task/ProjectTask.php
View
27 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 {
@@ -300,6 +307,26 @@ public function securityCipherSeed($path) {
}
/**
+ * 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
*
* @param string $path Project path
Please sign in to comment.
Something went wrong with that request. Please try again.