/** * Proxy Calls to Backend * * Once a source document has been supplied and a backend choosen. * This will then proxy any unresolved method calls through to backend * class. * * The user can then perform further configuration and custmoistation to * the backend easily before calling one of the output methods above. * * @param string $name * @param array $args * @return mixed */ public function __call($name, $args) { if ($this->offsetExists($name)) { return parent::__call($name, $args); } else { if (empty($this->backend)) { throw new RuntimeException('Backend Class not created yet!'); } return call_user_func_array([$this->backend, $name], $args); } }
/** * Method: __call * ========================================================================= * Okay so this is the magic method that makes it possible to do this: * * Route::get('/', function(){ return 'Hello World!'; }); * * For more info on how the laravel route api works, please see: * http://laravel.com/docs/routing * * > NOTE: Due to an odd PHP behaviour we are overriding the DI Containers * > __call method and no longer use the __callStatic method. See this * > stackoverflow link: http://stackoverflow.com/q/13232445 * * Parameters: * ------------------------------------------------------------------------- * - $name: The name of the method to call. * - $args: The argumnent array that is given to us. * * Returns: * ------------------------------------------------------------------------- * mixed * * Throws: * ------------------------------------------------------------------------- * - RuntimeException: When the router has not been installed. */ public function __call($name, $args) { if ($this->offsetExists($name)) { return parent::__call($name, $args); } else { if (empty(self::$router)) { throw new RuntimeException('You need to install a router first!'); } return call_user_func_array([self::$router, $name], $args); } }