mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
First attempt at trying to fix App::objects()
This commit is contained in:
parent
f3a5eaf2f7
commit
f3e2c0835f
1 changed files with 23 additions and 13 deletions
|
@ -421,13 +421,27 @@ class App {
|
|||
*/
|
||||
public static function objects($type, $path = null, $cache = true) {
|
||||
$objects = array();
|
||||
$extension = false;
|
||||
$extension = '/\.php$/';
|
||||
$directories = false;
|
||||
$name = $type;
|
||||
|
||||
if (isset(self::$legacy[$type . 's'])) {
|
||||
$type = self::$legacy[$type . 's'];
|
||||
}
|
||||
|
||||
if ($type === 'plugin') {
|
||||
$type = 'plugins';
|
||||
}
|
||||
|
||||
if ($type == 'plugins') {
|
||||
$extension = '/.*/';
|
||||
$includeDirectories = true;
|
||||
}
|
||||
|
||||
if ($type === 'file' && !$path) {
|
||||
return false;
|
||||
} elseif ($type === 'file') {
|
||||
$extension = true;
|
||||
$extension = '/.*/';
|
||||
$name = $type . str_replace(DS, '', $path);
|
||||
}
|
||||
|
||||
|
@ -436,25 +450,21 @@ class App {
|
|||
}
|
||||
|
||||
if (!isset(self::$__objects[$name]) || $cache !== true) {
|
||||
$types = self::$types;
|
||||
|
||||
if (!isset($types[$type])) {
|
||||
return false;
|
||||
}
|
||||
$objects = array();
|
||||
|
||||
if (empty($path)) {
|
||||
$path = self::${"{$type}s"};
|
||||
if (isset($types[$type]['core']) && $types[$type]['core'] === false) {
|
||||
array_pop($path);
|
||||
}
|
||||
$path = self::path($type);
|
||||
}
|
||||
$items = array();
|
||||
|
||||
foreach ((array)$path as $dir) {
|
||||
if ($dir != APP) {
|
||||
$items = self::__list($dir, $types[$type]['suffix'], $extension);
|
||||
$objects = array_merge($items, array_diff($objects, $items));
|
||||
$files = new RegexIterator(new DirectoryIterator($dir), $extension);
|
||||
foreach ($files as $file) {
|
||||
if (!$file->isDot() && (!$file->isDir() || $includeDirectories)) {
|
||||
$objects[] = basename($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue