Skip to content
Permalink
Browse files

Refactoring: clean up the foreach loop.

- cleaner code.
- reduce call of array_values and array_unique.
- clear intent of code.
  • Loading branch information...
basuke committed Oct 5, 2011
1 parent 810e2a4 commit fbf4449b9ec569d5c23e6546a6b9de6d76f661b1
Showing with 9 additions and 7 deletions.
  1. +9 −7 lib/Cake/Core/App.php
@@ -365,21 +365,23 @@ public static function build($paths = array(), $mode = App::PREPEND) {
}
foreach ($defaults as $type => $default) {
if (empty(self::$_packages[$type])) {
self::$_packages[$type] = $default;
if (!empty(self::$_packages[$type])) {
$path = self::$_packages[$type];
}
if (!empty($paths[$type])) {
$newPath = (array)$paths[$type];
if ($mode === App::PREPEND) {
$path = array_merge((array)$paths[$type], self::$_packages[$type]);
$path = array_merge($newPath, $path);
} else {
$path = array_merge(self::$_packages[$type], (array)$paths[$type]);
$path = array_merge($path, $newPath);
}
} else {
$path = self::$_packages[$type];
$path = array_values(array_unique($path));
}
self::$_packages[$type] = array_values(array_unique($path));
self::$_packages[$type] = $path;
}
}

0 comments on commit fbf4449

Please sign in to comment.
You can’t perform that action at this time.