diff --git a/lib/Model.php b/lib/Model.php index 36e0a4918..502590a3e 100644 --- a/lib/Model.php +++ b/lib/Model.php @@ -279,6 +279,14 @@ public function __construct(array $attributes=array(), $guard_attributes=true, $ $this->invoke_callback('after_construct',false); } + + /** + * Factory method to facilitate subclassing of Table if desired. + */ + public static function make_table($model_class_name) + { + return new Table($model_class_name); + } /** * Magic method which delegates to read_attribute(). This handles firing off getter methods, diff --git a/lib/Table.php b/lib/Table.php index 5f08e1895..e28585549 100644 --- a/lib/Table.php +++ b/lib/Table.php @@ -68,7 +68,7 @@ public static function load($model_class_name) { /* do not place set_assoc in constructor..it will lead to infinite loop due to relationships requesting the model's table, but the cache hasn't been set yet */ - self::$cache[$model_class_name] = new Table($model_class_name); + self::$cache[$model_class_name] = Model::make_table($model_class_name); self::$cache[$model_class_name]->set_associations(); } @@ -391,7 +391,7 @@ private function add_relationship($relationship) $this->relationships[$relationship->attribute_name] = $relationship; } - private function get_meta_data() + protected function get_meta_data() { // as more adapters are added probably want to do this a better way // than using instanceof but gud enuff for now