Commit 92aa3c56 authored by KR Moorhouse's avatar KR Moorhouse

Merge branch 'api-passthrough' into 'develop'

Should make Ninja_Forms() API calls more fluid

See merge request !3707
parents 5e38ff38 64378094
Pipeline #2507 passed with stages
in 5 minutes and 17 seconds
......@@ -78,6 +78,34 @@ class NF_Abstracts_ModelFactory
return $this;
}
/**
* PHP MAGIC method for catching undefined methods.
* Use this as a passthrough for methods of the form model.
*
* @param $method (String) The name of the called method.
* @param $args (Array) The arguments supplied to the method.
*
* @return (Mixed) Will match the return type of the supplied method.
*
* @since UPDATE_VERSION_ON_MERGE
*/
public function __call( $method, $args ) {
// If this is a method of the form model...
if ( method_exists( $this->_object, $method ) ) {
// Instantiate a reflector method.
$mirror = new ReflectionMethod( get_class( $this->_object ), $method );
// If the method is not private...
if ( ! $mirror->isPrivate() ) {
// If args were supplied...
if ( ! empty( $args ) ) {
// Pass them into the function.
return $this->_object->{$method}( $args );
}
return $this->_object->{$method}();
}
}
}
/**
* Returns the parent object set by the constructor for chained methods.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment