From 2f81c29defe52f81ebef88d1306b53dd57534ddf Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 14 Oct 2009 09:47:07 -0400 Subject: [PATCH] Updating $pluginPath loops to use App::pluginPath(). --- cake/console/cake.php | 15 ++++++--------- cake/console/libs/shell.php | 10 +--------- cake/dispatcher.php | 6 +----- cake/tests/lib/test_manager.php | 9 +++------ 4 files changed, 11 insertions(+), 29 deletions(-) diff --git a/cake/console/cake.php b/cake/console/cake.php index 5b08b43c9..cae27bc5c 100644 --- a/cake/console/cake.php +++ b/cake/console/cake.php @@ -222,18 +222,15 @@ class ShellDispatcher { */ function __buildPaths() { $paths = array(); - $pluginPaths = App::path('plugins'); if (!class_exists('Folder')) { require LIBS . 'folder.php'; } - foreach ($pluginPaths as $pluginPath) { - $Folder = new Folder($pluginPath); - list($plugins,) = $Folder->read(false, true); - foreach ((array)$plugins as $plugin) { - $path = $pluginPath . Inflector::underscore($plugin) . DS . 'vendors' . DS . 'shells' . DS; - if (file_exists($path)) { - $paths[] = $path; - } + $plugins = App::objects('plugin', null, false); + foreach ((array)$plugins as $plugin) { + $pluginPath = App::pluginPath($plugin); + $path = $pluginPath . 'vendors' . DS . 'shells' . DS; + if (file_exists($path)) { + $paths[] = $path; } } diff --git a/cake/console/libs/shell.php b/cake/console/libs/shell.php index eb5a2436f..246e312b4 100644 --- a/cake/console/libs/shell.php +++ b/cake/console/libs/shell.php @@ -649,15 +649,7 @@ class Shell extends Object { * @return string $path path to the correct plugin. **/ function _pluginPath($pluginName) { - $pluginPaths = App::path('plugins'); - $pluginDirName = Inflector::underscore($pluginName); - - foreach ($pluginPaths as $path) { - if (is_dir($path . $pluginDirName)) { - return $path . $pluginDirName . DS ; - } - } - return $pluginPaths[0] . $pluginDirName . DS; + return App::pluginPath($pluginName); } } ?> \ No newline at end of file diff --git a/cake/dispatcher.php b/cake/dispatcher.php index bdac74acd..4aa7429e2 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -648,11 +648,7 @@ class Dispatcher extends Object { if ($pos > 0) { $plugin = substr($url, 0, $pos - 1); $url = preg_replace('/^' . preg_quote($plugin, '/') . '\//i', '', $url); - $pluginPaths = App::path('plugins'); - $count = count($pluginPaths); - for ($i = 0; $i < $count; $i++) { - $paths[] = $pluginPaths[$i] . $plugin . DS . 'vendors' . DS; - } + $paths[] = App::pluginPath($plugin) . 'vendors' . DS; } $paths = array_merge($paths, App::path('vendors')); diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index c986918f6..596c8da3a 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -357,12 +357,9 @@ class TestManager { } } else if (!empty($this->pluginTest)) { $_pluginBasePath = APP . 'plugins' . DS . $this->pluginTest . DS . 'tests'; - $pluginPaths = App::path('plugins'); - foreach ($pluginPaths as $path) { - if (file_exists($path . $this->pluginTest . DS . 'tests')) { - $_pluginBasePath = $path . $this->pluginTest . DS . 'tests'; - break; - } + $pluginPath = App::pluginPath($this->pluginTest); + if (file_exists($pluginPath . DS . 'tests')) { + $_pluginBasePath = $pluginPath . DS . 'tests'; } $result = $_pluginBasePath . DS . $type; } else {