Files
safekat/ci4/app/Controllers/Test.php
2023-04-27 18:29:38 +02:00

73 lines
2.3 KiB
PHP

<?php
namespace App\Controllers;
class Test extends BaseController
{
function __construct()
{
}
public function index()
{
try {
helper('filesystem');
helper('directory');
if(strtolower(PHP_OS) == 'linux'){
$compatibility = '/';
}else{
$compatibility = '\\';
}
if(empty($controller)){
$map = directory_map(APPPATH.'Controllers');
foreach ($map as $key=>$item)
{
if(!strpos(strtolower($key),$compatibility)){
var_dump($key);
$name = str_replace('.php', '', $item);
if(!getIgnoreController($name)){
$controllers[] = [
'name' => $name,
'path' => '',
'methods' => get_class_methods('App\Controllers\\'.$name)
];
}
}else{
foreach ($item as $subitem){
$name = str_replace('.php', '', $subitem);
if(!getIgnoreController($name)) {
$controllers[] = [
'name' => $name,
'path' => $key,
'methods' => get_class_methods('App\Controllers\\' . str_replace('/', '\\', $key) . $name)
];
}
}
}
}
}else{
$array = explode('/',$controller);
$dir = count($array) > 1 ? $array[0] : '';
$name = count($array) > 1 ? '\\'.$array[1] : $array[0];
$controllers[] = [
'name' => $name,
'path' => $dir,
'methods' => get_class_methods('App\Controllers\\'.str_replace('/','\\',$dir).$name)
];
}
/*echo '<pre>';
var_dump($controllers);
echo '<pre>';
dd();
*/
} catch (Exception $e) {
return [];
}
}
}