[Solar-svn] Revision 3272
pmjones at solarphp.com
pmjones at solarphp.com
Tue Jul 29 22:01:22 CDT 2008
Solar_Factory: [NEW] Abstract base class for factory classes (Auth, Cache, Sql, etc).
Added: trunk/Solar/Factory.php
===================================================================
--- trunk/Solar/Factory.php (rev 0)
+++ trunk/Solar/Factory.php 2008-07-30 03:01:22 UTC (rev 3272)
@@ -0,0 +1,41 @@
+<?php
+abstract class Solar_Factory extends Solar_Base
+{
+ protected $_Solar_Factory = array(
+ 'adapter' => null,
+ );
+
+ /**
+ *
+ * Disallow all calls to methods besides factory() and the existing
+ * support methods.
+ *
+ * @return void
+ *
+ */
+ final public function __call($method, $params)
+ {
+ throw $this->_exception('ERR_NOT_ADAPTER_INSTANCE', array(
+ 'method' => $method,
+ 'params' => $params,
+ ));
+ }
+
+ /**
+ *
+ * Factory method for returning adapter objects.
+ *
+ * @return object
+ *
+ */
+ public function factory()
+ {
+ // bring in the config and get the adapter class.
+ $config = $this->_config;
+ $class = $config['adapter'];
+ unset($config['adapter']);
+
+ // return the factoried adapter object
+ return new $class($config);
+ }
+}
\ No newline at end of file
More information about the Solar-svn
mailing list