d0cac19a26
Stable
33 lines
806 B
PHP
33 lines
806 B
PHP
<?php
|
|
abstract class Libs_Controller extends Zend_Controller_Action
|
|
{
|
|
protected static $_loadedTables = array();
|
|
|
|
public function __get($prop)
|
|
{
|
|
$class = false;
|
|
if (substr($prop, 0, 5) == 'table') {
|
|
$class = 'Table_' . substr($prop, 5);
|
|
}else if (substr($prop, 0, 6) == 'object') {
|
|
$class = 'Object_' . substr($prop, 6);
|
|
}
|
|
|
|
if (!$class) {
|
|
trigger_error("Access to undefined property $prop", E_USER_WARNING);
|
|
return;
|
|
}
|
|
return self::loadTable($class);
|
|
}
|
|
|
|
public static function loadTable($class)
|
|
{
|
|
if (array_key_exists($class, self::$_loadedTables)) {
|
|
return self::$_loadedTables[$class];
|
|
}
|
|
if (!class_exists($class)) {
|
|
throw new Libs_Exception("Class $class not found");
|
|
}
|
|
self::$_loadedTables[$class] = new $class;
|
|
return self::$_loadedTables[$class];
|
|
}
|
|
} |