gpt4 book ai didi

plugins - 列出所有命名空间和插件 (Octobercms)

转载 作者:行者123 更新时间:2023-12-01 11:19:24 25 4
gpt4 key购买 nike

我是 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>');

}

关于plugins - 列出所有命名空间和插件 (Octobercms),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45755311/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com