resource = get_class($this); $class_parts = explode('\\', $this->resource); $this->table = end($class_parts); $this->database = database::get_instance(); $this->request = request::get_instance(); $this->setting = setting::get_instance(); $this->session = session::get_instance(); } /** * Shortcut method for doing API calls within the API. This will create an * instance of the resource you want and call the method you want with the * arguments you want. * * @param string $resource The resource to use. * @param string $method The method to call. * @param mixed $arguments The arguments to send. If not an array then * assumes a single argument. * * @return mixed */ public function api($resource, $method, $arguments = []) { if(is_array($arguments) === false) { $arguments = [$arguments]; } $resource_instance = new $resource(); return call_user_func_array([$resource_instance, $method], $arguments); } }