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
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);
Blesta Addons Posted September 10, 2014 Author Report Posted September 10, 2014 On 9/10/2014 at 12:00 AM, Tyson said: 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 ?
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. On 9/10/2014 at 12:11 AM, naja7host said: 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
Blesta Addons Posted September 10, 2014 Author Report Posted September 10, 2014 On 9/10/2014 at 12:14 AM, Tyson said: 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 On 9/10/2014 at 12:14 AM, Tyson said: 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
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']);
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
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now