Skip to content

Commit

Permalink
Replacing $pluginPath loops with App::pluginPath(). Minor optimizatio…
Browse files Browse the repository at this point in the history
…n for App::pluginPath().
  • Loading branch information
markstory committed Oct 14, 2009
1 parent 38f65bd commit de8f251
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 29 deletions.
6 changes: 3 additions & 3 deletions cake/libs/configure.php
Expand Up @@ -677,9 +677,9 @@ function build($paths = array(), $reset = false) {
function pluginPath($plugin) {
$_this =& App::getInstance();
$pluginDir = Inflector::underscore($plugin);
foreach ($_this->plugins as $path) {
if (is_dir($path . $pluginDir)) {
return $path . $pluginDir . DS ;
for ($i = 0, $length = count($_this->plugins); $i < $length; $i++) {
if (is_dir($_this->plugins[$i] . $pluginDir)) {
return $_this->plugins[$i] . $pluginDir . DS ;
}
}
return $_this->plugins[0] . $pluginDir . DS;
Expand Down
6 changes: 1 addition & 5 deletions cake/libs/i18n.php
Expand Up @@ -272,14 +272,10 @@ function __bindTextDomain($domain) {
$plugins = App::objects('plugin');

if (!empty($plugins)) {
$pluginPaths = App::path('plugins');

foreach ($plugins as $plugin) {
$plugin = Inflector::underscore($plugin);
if ($plugin === $domain) {
foreach ($pluginPaths as $pluginPath) {
$searchPaths[] = $pluginPath . $plugin . DS . 'locale' . DS;
}
$searchPaths[] = App::pluginPath($plugin) . DS . 'locale' . DS;
$searchPaths = array_reverse($searchPaths);
break;
}
Expand Down
7 changes: 1 addition & 6 deletions cake/libs/view/view.php
Expand Up @@ -937,12 +937,7 @@ function _paths($plugin = null, $cached = true) {
$paths[] = $viewPaths[$i] . 'plugins' . DS . $plugin . DS;
}
}
$pluginPaths = App::path('plugins');
$count = count($pluginPaths);

for ($i = 0; $i < $count; $i++) {
$paths[] = $pluginPaths[$i] . $plugin . DS . 'views' . DS;
}
$paths[] = App::pluginPath($plugin) . 'views' . DS;
}
$paths = array_merge($paths, $viewPaths);

Expand Down
19 changes: 4 additions & 15 deletions cake/tests/lib/cake_test_case.php
@@ -1,6 +1,4 @@
<?php
/* SVN FILE: $Id$ */

/**
* CakeTestCase file
*
Expand All @@ -9,20 +7,17 @@
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
*
* Licensed under The Open Group Test Suite License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake
* @subpackage cake.cake.tests.libs
* @since CakePHP(tm) v 1.2.0.4667
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
if (!class_exists('dispatcher')) {
Expand Down Expand Up @@ -67,7 +62,7 @@ function testCase(&$testCase) {
* @param array $params
* @param boolean $missingAction
* @return Controller
* @access proptected
* @access protected
*/
function _invoke(&$controller, $params, $missingAction = false) {
$this->controller =& $controller;
Expand Down Expand Up @@ -775,13 +770,7 @@ function _loadFixtures() {
TESTS . 'fixtures',
VENDORS . 'tests' . DS . 'fixtures'
);
$pluginPaths = App::path('plugins');
foreach ($pluginPaths as $path) {
if (file_exists($path . $pluginName . DS . 'tests' . DS. 'fixtures')) {
$fixturePaths[0] = $path . $pluginName . DS . 'tests' . DS. 'fixtures';
break;
}
}
$fixturesPaths[0] = App::pluginPath($pluginName) . DS . 'tests' . DS . 'fixtures';
} else {
$fixturePaths = array(
TESTS . 'fixtures',
Expand Down

0 comments on commit de8f251

Please sign in to comment.