Browse Source

Update UpgradeShell for App classes.

Correctly move AppController and AppModel.
Fixes #2472
mark_story 14 years ago
parent
commit
b6040aec5a
1 changed files with 32 additions and 0 deletions
  1. 32 0
      lib/Cake/Console/Command/UpgradeShell.php

+ 32 - 0
lib/Cake/Console/Command/UpgradeShell.php

@@ -169,7 +169,10 @@ class UpgradeShell extends AppShell {
 				}
 			}
 		}
+	
 		$this->_moveViewFiles();
+		$this->_moveAppClasses();
+
 		$sourceDirs = array(
 			'.' => array('recursive' => false),
 			'Console',
@@ -594,6 +597,35 @@ class UpgradeShell extends AppShell {
 	}
 
 /**
+ * Move the AppController, and AppModel classes.
+ *
+ * @return void
+ */
+	protected function _moveAppClasses() {
+		$files = array(
+			APP . 'app_controller.php' => APP . 'Controller' . DS . 'AppController.php',
+			APP . 'controllers' . DS .'app_controller.php' => APP . 'Controller' . DS . 'AppController.php',
+			APP . 'app_model.php' => APP . 'Model' . DS . 'AppModel.php',
+			APP . 'models' . DS . 'app_model.php' => APP . 'Model' . DS . 'AppModel.php',
+		);
+		foreach ($files as $old => $new) {
+			if (file_exists($old)) {
+				$this->out(__d('cake_console', 'Moving %s to %s', $old, $new));
+
+				if ($this->params['dry-run']) {
+					continue;
+				}
+				if ($this->params['git']) {
+					exec('git mv -f ' . escapeshellarg($old) . ' ' . escapeshellarg($old . '__'));
+					exec('git mv -f ' . escapeshellarg($old . '__') . ' ' . escapeshellarg($new));
+				} else {
+					rename($old, $new);
+				}
+			}
+		}
+	}
+
+/**
  * Move application php files to where they now should be
  *
  * Find all php files in the folder (honoring recursive) and determine where cake expects the file to be