mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Refactoring: clean up the foreach loop.
- cleaner code. - reduce call of array_values and array_unique. - clear intent of code.
This commit is contained in:
parent
810e2a4ffe
commit
fbf4449b9e
1 changed files with 14 additions and 12 deletions
|
@ -365,21 +365,23 @@ class App {
|
|||
}
|
||||
|
||||
foreach ($defaults as $type => $default) {
|
||||
if (empty(self::$_packages[$type])) {
|
||||
self::$_packages[$type] = $default;
|
||||
}
|
||||
|
||||
if (!empty($paths[$type])) {
|
||||
if ($mode === App::PREPEND) {
|
||||
$path = array_merge((array)$paths[$type], self::$_packages[$type]);
|
||||
} else {
|
||||
$path = array_merge(self::$_packages[$type], (array)$paths[$type]);
|
||||
}
|
||||
} else {
|
||||
if (!empty(self::$_packages[$type])) {
|
||||
$path = self::$_packages[$type];
|
||||
}
|
||||
|
||||
self::$_packages[$type] = array_values(array_unique($path));
|
||||
if (!empty($paths[$type])) {
|
||||
$newPath = (array)$paths[$type];
|
||||
|
||||
if ($mode === App::PREPEND) {
|
||||
$path = array_merge($newPath, $path);
|
||||
} else {
|
||||
$path = array_merge($path, $newPath);
|
||||
}
|
||||
|
||||
$path = array_values(array_unique($path));
|
||||
}
|
||||
|
||||
self::$_packages[$type] = $path;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue