SchemaFactory.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. class SchemaFactory {
  3. public static function loadDefaultObject($name) {
  4. $objClassName = "Schema_{$name}StorageAcl";
  5. if (!Lib::tryLoadClass($objClassName)) throw new HttpException("Not implemented - storage object not found '{$name}'", 501);
  6. return new $objClassName();
  7. }
  8. public static function loadTableObject($tableName, $name) {
  9. $className = "Schema_DefaultDb_{$tableName}_{$name}StorageAcl";// TODO: load by Factory class which build from schema file
  10. // list($nsUri, $prefix, $name) = Api_WfsNs::parseObjectNsUri('default_objects/AccessOwner');
  11. $path = implode('/', [
  12. APP_PATH_LIB,
  13. 'Schema',
  14. 'DefaultDb',
  15. strtolower($tableName),
  16. implode('/', explode('_', $name)).'StorageAcl.php',
  17. ]);
  18. if (file_exists($path)) {
  19. require_once $path;
  20. } else {
  21. $path = implode('/', [
  22. APP_PATH_LIB,
  23. 'Schema',
  24. 'DefaultDb',
  25. strtolower($tableName),
  26. $name.'StorageAcl.php',
  27. ]);
  28. if (file_exists($path)) {
  29. require_once $path;
  30. }
  31. }
  32. if (!class_exists($className)) {
  33. throw new HttpException("Not implemented - default db storage object not found 'default_db/{$tableName}/{$name}'", 501);
  34. }
  35. return new $className;
  36. }
  37. }