Skip to content
Browse files

Improving the regex and moving more files around.

- Making the regex case insensitive so it can also matches capital C in class (ie. Class).
- Adding a new protected method to move view files, the directory will be camelized.
  • Loading branch information...
1 parent ceed424 commit 0bcb8d0dfa5c33fccd8e7ff880385e4e036b209c @renan renan committed
Showing with 36 additions and 2 deletions.
  1. +36 −2 lib/Cake/Console/Command/UpgradeShell.php
View
38 lib/Cake/Console/Command/UpgradeShell.php
@@ -132,7 +132,6 @@ public function locations() {
}
if (is_dir('plugins')) {
-
$Folder = new Folder('plugins');
list($plugins) = $Folder->read();
foreach($plugins as $plugin) {
@@ -143,6 +142,8 @@ public function locations() {
chdir($cwd);
}
+ $this->_moveViewFiles();
+
$moves = array(
'libs' => 'Lib',
'tests' => 'Test',
@@ -181,7 +182,7 @@ public function locations() {
$defaultOptions = array(
'recursive' => true,
'checkFolder' => true,
- 'regex' => '@class (\S*) .*{@'
+ 'regex' => '@class (\S*) .*{@i'
);
foreach($sourceDirs as $dir => $options) {
if (is_numeric($dir)) {
@@ -507,6 +508,39 @@ public function components() {
}
/**
+ * Move application views files to where they now should be
+ *
+ * Find all view files in the folder and determine where cake expects the file to be
+ *
+ * @return void
+ */
+ protected function _moveViewFiles() {
+ if (!is_dir('views')) {
+ return;
+ }
+
+ $dirs = scandir('views');
+ foreach ($dirs as $old) {
+ if (!is_dir('views' . DS . $old) || $old === '.' || $old === '..') {
+ continue;
+ }
+
+ $new = 'View' . DS . Inflector::camelize($old);
+ $old = 'views' . DS . $old;
+
+ $this->out(__d('cake_console', 'Moving %s to %s', $old, $new));
+ if (!$this->params['dry-run']) {
+ if ($this->params['git']) {
+ exec('git mv -f ' . escapeshellarg($old) . ' ' . escapeshellarg($new));
+ } else {
+ $Folder = new Folder($old);
+ $Folder->move($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

0 comments on commit 0bcb8d0

Please sign in to comment.
Something went wrong with that request. Please try again.