/** * Method always called when making an API request. * It checks several things before actually calling the real method on the given module. * * It also logs the API calls, with the parameters values, the returned value, the performance, etc. * You can enable logging in config/global.ini.php (log_api_call) * * @param string The method name * @param array The parameters * * @throws Piwik_Access_NoAccessException */ public function __call($methodName, $parameterValues) { $returnedValue = null; try { $this->registerClass(self::$classCalled); $className = $this->getClassNameFromModule(self::$classCalled); // instanciate the object $object = call_user_func(array($className, "getInstance")); // check method exists $this->checkMethodExists($className, $methodName); // first check number of parameters do match $this->checkNumberOfParametersMatch($className, $methodName, $parameterValues); // start the timer $timer = new Piwik_Timer(); // call the method $returnedValue = call_user_func_array(array($object, $methodName), $parameterValues); // log the API Call $parameterNamesDefaultValues = $this->getParametersList($className, $methodName); Zend_Registry::get('logger_api_call')->log(self::$classCalled, $methodName, $parameterNamesDefaultValues, $parameterValues, $timer->getTimeMs(), $returnedValue); } catch (Piwik_Access_NoAccessException $e) { throw $e; } self::$classCalled = null; return $returnedValue; }