| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- class SchemaFactory {
- public static function loadDefaultObject($name) {
- static $_cache = [];
- if (array_key_exists($name, $_cache)) return $_cache[$name];
- $objClassName = "Schema_{$name}StorageAcl";
- if (!Lib::tryLoadClass($objClassName)) throw new HttpException("Not implemented - storage object not found '{$name}'", 501);
- $_cache[$name] = new $objClassName();
- return $_cache[$name];
- }
- public static function loadTableObject($tableName, $name) {
- $className = "Schema_DefaultDb_{$tableName}_{$name}StorageAcl";// TODO: load by Factory class which build from schema file
- // list($nsUri, $prefix, $name) = Api_WfsNs::parseObjectNsUri('default_objects/AccessOwner');
- $path = implode('/', [
- APP_PATH_LIB,
- 'Schema',
- 'DefaultDb',
- strtolower($tableName),
- implode('/', explode('_', $name)).'StorageAcl.php',
- ]);
- if (file_exists($path)) {
- require_once $path;
- } else {
- $path = implode('/', [
- APP_PATH_LIB,
- 'Schema',
- 'DefaultDb',
- strtolower($tableName),
- $name.'StorageAcl.php',
- ]);
- if (file_exists($path)) {
- require_once $path;
- }
- }
- if (!class_exists($className)) {
- throw new HttpException("Not implemented - default db storage object not found 'default_db/{$tableName}/{$name}'", 501);
- }
- return new $className;
- }
- }
|