Browse files

Provides a transparent interface for calling custom adapter methods.

  • Loading branch information...
1 parent dea12e1 commit af70d339d26895c1743555c2c3515b1246d427e8 Jim Safley committed May 17, 2011
Showing with 20 additions and 0 deletions.
  1. +20 −0 lib/Scripto.php
View
20 lib/Scripto.php
@@ -81,6 +81,26 @@ public function __construct(Scripto_Adapter_Interface $adapter, $mediawiki)
}
/**
+ * Provide a transparent interface for calling custom adapter methods.
+ *
+ * This makes it possible to call custom adapter methods (those not required
+ * by Scripto_Adapter_Interface) directly from the Scripto object.
+ *
+ * @see Scripto_Adapter_Interface
+ * @param string $name
+ * @param array $args
+ * @return mixed
+ */
+ public function __call($name, $args)
+ {
+ if (!method_exists($this->_adapter, $name)) {
+ require_once 'Scripto/Adapter/Exception.php';
+ throw new Scripto_Adapter_Exception('The provided adapter method "' . $name . '" does not exist.');
+ }
+ return call_user_func_array(array($this->_adapter, $name), $args);
+ }
+
+ /**
* Check whether the specified document exists in the external system.
*
* @uses Scripto_Adapter_Interface::documentExists()

0 comments on commit af70d33

Please sign in to comment.