mirror of
https://github.com/humhub/humhub.git
synced 2025-02-20 08:05:23 +01:00
Removed deprecated code
This commit is contained in:
parent
f80e21d303
commit
e14de806fc
@ -30,38 +30,19 @@ class ModuleAutoLoader implements BootstrapInterface
|
||||
public function bootstrap($app)
|
||||
{
|
||||
$modules = self::locateModules();
|
||||
|
||||
Yii::$app->moduleManager->registerBulk($modules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find available modules
|
||||
* @deprecated 1.3 replace call for locateModules with findModules and handle caching outside of method (e.g. in boostrap)
|
||||
* @return array|bool|mixed
|
||||
* @return array
|
||||
*/
|
||||
public static function locateModules()
|
||||
{
|
||||
$modules = Yii::$app->cache->get(self::CACHE_ID);
|
||||
|
||||
if ($modules === false) {
|
||||
$modules = [];
|
||||
foreach (Yii::$app->params['moduleAutoloadPaths'] as $modulePath) {
|
||||
$modulePath = Yii::getAlias($modulePath);
|
||||
foreach (scandir($modulePath) as $moduleId) {
|
||||
if ($moduleId == '.' || $moduleId == '..') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$moduleDir = $modulePath . DIRECTORY_SEPARATOR . $moduleId;
|
||||
if (is_dir($moduleDir) && is_file($moduleDir . DIRECTORY_SEPARATOR . 'config.php')) {
|
||||
try {
|
||||
$modules[$moduleDir] = require($moduleDir . DIRECTORY_SEPARATOR . 'config.php');
|
||||
} catch (\Exception $ex) {
|
||||
Yii::error($ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($modules === false || YII_DEBUG) {
|
||||
$modules = static::findModules(Yii::$app->params['moduleAutoloadPaths']);
|
||||
Yii::$app->cache->set(self::CACHE_ID, $modules);
|
||||
}
|
||||
|
||||
@ -73,7 +54,7 @@ class ModuleAutoLoader implements BootstrapInterface
|
||||
* @param array $paths
|
||||
* @return array
|
||||
*/
|
||||
public static function findModules($paths)
|
||||
private static function findModules($paths)
|
||||
{
|
||||
$folders = [];
|
||||
foreach ($paths as $path) {
|
||||
@ -98,14 +79,17 @@ class ModuleAutoLoader implements BootstrapInterface
|
||||
* @param string $path
|
||||
* @return array
|
||||
*/
|
||||
public static function findModulesByPath($path)
|
||||
private static function findModulesByPath($path)
|
||||
{
|
||||
$hasConfigurationFile = function ($path) {
|
||||
return is_file($path . DIRECTORY_SEPARATOR . self::CONFIGURATION_FILE);
|
||||
};
|
||||
|
||||
try {
|
||||
return FileHelper::findDirectories(Yii::getAlias($path, true), ['filter' => $hasConfigurationFile, 'recursive' => false]);
|
||||
return FileHelper::findDirectories(
|
||||
Yii::getAlias($path, true),
|
||||
['filter' => $hasConfigurationFile, 'recursive' => false]
|
||||
);
|
||||
} catch (yii\base\InvalidArgumentException $e) {
|
||||
return [];
|
||||
}
|
||||
|
@ -79,14 +79,6 @@ class ModuleAutoLoaderTest extends Unit
|
||||
array_pop(Yii::$app->params['moduleAutoloadPaths']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test module loading by path
|
||||
* @dataProvider dataModuleLoadingByPath
|
||||
*/
|
||||
public function testModuleLoadingByPath($path, $count)
|
||||
{
|
||||
$this->assertCount($count, ModuleAutoLoader::findModulesByPath($path));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return test cases for module loading by path
|
||||
@ -100,15 +92,4 @@ class ModuleAutoLoaderTest extends Unit
|
||||
['@invalid/folder', 0]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that locateModules and findModules return the same list of modules
|
||||
*/
|
||||
public function testLocateAndFindModules()
|
||||
{
|
||||
$this->assertEquals(
|
||||
ModuleAutoLoader::locateModules(),
|
||||
ModuleAutoLoader::findModules(Yii::$app->params['moduleAutoloadPaths'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user