bgultekin / laravel4-datatables-package

Server-side handler of DataTables Jquery Plugin for Laravel 4
267 stars 108 forks source link

Use camelCase style. #93

Closed anhskohbo closed 10 years ago

anhskohbo commented 10 years ago

Use camelCase style inside of snake_case

yajra commented 10 years ago

Your removeColumn function will fail because of $names = func_get_args();. I suggest you duplicate the remove_column function instead of alias. Have also done the same on my fork and have encountered it.

btw: I think it's Camel Case and not Came Case?

ktunkiewicz commented 10 years ago

Much more elegant method of camelCase (and CamelCase) to snake_case conversion below. Just put it anywhere in Datatables class.

/**
 * PR #93
 * camelCase to snake_case magic method
 */
public function __call($name, $arguments)
{
    $name = strtolower(preg_replace('/([^A-Z])([A-Z])/', "$1_$2", $name));
    if (method_exists($this, $name)) {
        return call_user_func_array(array($this, $name),$arguments);
    } else {
        trigger_error('Call to undefined method '.__CLASS__.'::'.$name.'()', E_USER_ERROR);
    }
}

Tested and ready to go. In case of not finding the method it triggers native php error that is handled properly by Laravel (shows the debug info etc.)

ktunkiewicz commented 10 years ago

Anhskohbo i'm going to add my implementation of this functionality into branch. Your proposed change is simply not universal enough and will needlessly expand the code. I hope you don't mind, are you OK with that?

anhskohbo commented 10 years ago

never mind :)