From a8f685cd03a9d64c589e8d637f4ff6a23b61034b Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Tue, 12 Mar 2013 09:29:25 -0400 Subject: [PATCH] Added support for supportsMethod() when checking capabilities. --- module/VuFind/src/VuFind/ILS/Connection.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/module/VuFind/src/VuFind/ILS/Connection.php b/module/VuFind/src/VuFind/ILS/Connection.php index 8d0f88bdb78..7fe9e966cad 100644 --- a/module/VuFind/src/VuFind/ILS/Connection.php +++ b/module/VuFind/src/VuFind/ILS/Connection.php @@ -420,14 +420,26 @@ class Connection * method; false otherwise. * * @param string $method Method to check + * @param array $params Array of passed parameters (optional) * * @return bool */ - public function checkCapability($method) + public function checkCapability($method, $params = array()) { + // If possible, we want to try to check the capability without the expense + // of instantiating an object: if (is_callable(array($this->getDriverClass(), $method))) { return true; } + + // The problem with is_callable is that it doesn't work well for classes + // implementing the __call() magic method; to compensate for this, ILS + // drivers using __call() must also implement supportsMethod(). + if (is_callable(array($this->getDriverClass(), 'supportsMethod'))) { + return $this->getDriver()->supportsMethod($method, $params); + } + + // If we got this far, the feature is unsupported: return false; } /** @@ -443,7 +455,7 @@ class Connection */ public function __call($methodName, $params) { - if ($this->checkCapability($methodName)) { + if ($this->checkCapability($methodName, $params)) { return call_user_func_array( array($this->getDriver(), $methodName), $params ); -- GitLab