| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- class SchemaFactory {
- public static function loadDefaultObject($namespace) {
- static $_cache = [];
- $clsName = str_replace('/', '_', $namespace);
- if (array_key_exists($clsName, $_cache)) return $_cache[$clsName];
- $objClassName = "Schema_{$clsName}StorageAcl";
- if (!Lib::tryLoadClass($objClassName)) throw new HttpException("Not implemented - storage object not found '{$namespace}'", 501);
- $_cache[$clsName] = new $objClassName();
- return $_cache[$clsName];
- }
- 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;
- }
- }
|