列出所有命名空间和插件(十月)



我是 octobercms 的新手,我想列出我项目中所有现有的命名空间、插件和模型,我该怎么做?

public function test_stat()
{
if(is_dir(('./plugins/'))){
$pluginPath = './plugins/' ;
$namespaces_list = [];
$namespaces = scandir($pluginPath);
foreach ($namespaces as $namespace){
if(!in_array($namespace, ['.', '..'])){
$plugins = scandir($pluginPath . $namespace);
if(count($plugins)>2){
$plugins = array_values($plugins);
$plugins_list = [];
foreach ($plugins as $plugin){
if(!in_array($plugin, ['.', '..'])){
if(is_dir($pluginPath . $namespace . '/' . $plugin . '/models')){
$modelsPath = $pluginPath . $namespace . '/' . $plugin . '/models';
$models = scandir($modelsPath);
$models_list = [];
foreach ($models as $model){
if(is_dir($modelsPath . '/' . $model) && !in_array($model, ['.', '..'])){
if(file_exists($modelsPath . '/' . $model . '/columns.yaml')){
$models_list[] = $model;
}
}
}
if(count($models_list) > 0){
$pluginNamespace = $namespace . '_' . $plugin;
$tables = DB::select("SHOW TABLES LIKE '" . $pluginNamespace . "%'");
$plugins_list[] = [
"name"      => $plugin,
"models"    => $models_list,
"tables"    => $tables
];
}
}
}
}
$namespace_obj = NULL;
if(count($plugins_list) > 0){
$namespace_obj = [
"name"      => $namespace,
"plugins"   => $plugins_list
];
}
if($namespace_obj !== NULL){
$namespaces_list[] = $namespace_obj;
}
}
}
}
dump( $namespaces_list );

}else{
echo "";
return false;
}
die('<br>test<br>');
}

https://secure.php.net/manual/en/function.get-declared-classes.php

echo dump(get_declared_classes());

dd(get_declared_classes());

最新更新