[Solar-svn] Revision 3003
pmjones at solarphp.com
pmjones at solarphp.com
Mon Mar 17 14:50:07 CDT 2008
Solar_Role_Adapter: [ADD] Magic method __call() to take "isRoleName()" and convert to "is('role_name')".
Modified: trunk/Solar/Role/Adapter.php
===================================================================
--- trunk/Solar/Role/Adapter.php 2008-03-17 15:19:35 UTC (rev 3002)
+++ trunk/Solar/Role/Adapter.php 2008-03-17 19:50:06 UTC (rev 3003)
@@ -95,6 +95,34 @@
/**
*
+ * Provides magic "isRoleName()" to map to "is('role_name')".
+ *
+ * @param string $method The called method name.
+ *
+ * @param array $params Parameters passed to the method.
+ *
+ * @return bool
+ *
+ */
+ public function __call($method, $params)
+ {
+ if (substr($method, 2) == 'is') {
+ // convert from isRoleName to role_name
+ $role = substr($method, 2);
+ $role = preg_replace('/([a-z])([A-Z])/', '$1_$2', $role);
+ $role = strtolower($role);
+ // call is() on the role name
+ return $this->is($role);
+ } else {
+ throw $this->_exception('ERR_METHOD_NOT_IMPLEMENTED', array(
+ 'method' => $method,
+ 'params' => $params,
+ ));
+ }
+ }
+
+ /**
+ *
* Load the list of roles for the given user from the adapter.
*
* @param string $handle The username to load roles for.
More information about the Solar-svn
mailing list