Blesta Addons Posted September 9, 2014 Report Posted September 9, 2014 is there any easy code to get all controllers and thier public function ? my actal code use the get_file_content with scandir function . i ned a simple way if already exist in blesta Quote
Tyson Posted September 10, 2014 Report Posted September 10, 2014 Looks like you already search for the files, so then you can find the class methods: $class = "className" $methods = get_class_methods($class); Quote
Blesta Addons Posted September 10, 2014 Author Report Posted September 10, 2014 Looks like you already search for the files, so then you can find the class methods: $class = "className" $methods = get_class_methods($class); already i'm using this method . but a lot of code , $scaned_dir = array_diff(scandir(CONTROLLERDIR), array('..', '.')); then i have made a regex to rename the file name (admin_client.php --- to AdminClient ) then i use this in the get_class_methods , $class_methods = get_class_methods('AdminClient'); foreach ($class_methods as $method_name) { $result[] = $method_name; } all this in side a boucle of result files scan , so there is no built-in function todo this ? Quote
Tyson Posted September 10, 2014 Report Posted September 10, 2014 I don't see a need for all controllers and controller methods to be fetched in/by Blesta. then i have made a regex to rename the file name (admin_client.php --- to AdminClient ) then i use this in the get_class_methods , You could improve that by using Loader::toCamelCase Quote
Blesta Addons Posted September 10, 2014 Author Report Posted September 10, 2014 I don't see a need for all controllers and controller methods to be fetched in/by Blesta. you will see the need when i will release my new magic plugin soon You could improve that by using Loader::toCamelCase this has saved me three like of code EDIT ; still exist a small prob $controller_name .= Loader::toCamelCase("admin_clients.php"); result AdminClients.php what i need just AdminClients Quote
flangefrog Posted September 10, 2014 Report Posted September 10, 2014 $controller_name .= Loader::toCamelCase(basename("admin_clients.php", ".php")); Or $controller_name .= Loader::toCamelCase(pathinfo("admin_clients.php")['filename']); Quote
Blesta Addons Posted September 10, 2014 Author Report Posted September 10, 2014 i got it by the simple way $controller = strstr($dirfile, '.', true); flangefrog 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.