Factory.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. class FreshRSS_Factory {
  3. public static function createUserDao($username = null) {
  4. return new FreshRSS_UserDAO($username);
  5. }
  6. public static function createCategoryDao($username = null) {
  7. return new FreshRSS_CategoryDAO($username);
  8. }
  9. public static function createFeedDao($username = null) {
  10. $conf = Minz_Configuration::get('system');
  11. switch ($conf->db['type']) {
  12. case 'sqlite':
  13. return new FreshRSS_FeedDAOSQLite($username);
  14. default:
  15. return new FreshRSS_FeedDAO($username);
  16. }
  17. }
  18. public static function createEntryDao($username = null) {
  19. $conf = Minz_Configuration::get('system');
  20. switch ($conf->db['type']) {
  21. case 'sqlite':
  22. return new FreshRSS_EntryDAOSQLite($username);
  23. case 'pgsql':
  24. return new FreshRSS_EntryDAOPGSQL($username);
  25. default:
  26. return new FreshRSS_EntryDAO($username);
  27. }
  28. }
  29. public static function createTagDao($username = null) {
  30. $conf = Minz_Configuration::get('system');
  31. switch ($conf->db['type']) {
  32. case 'sqlite':
  33. return new FreshRSS_TagDAOSQLite($username);
  34. case 'pgsql':
  35. return new FreshRSS_TagDAOPGSQL($username);
  36. default:
  37. return new FreshRSS_TagDAO($username);
  38. }
  39. }
  40. public static function createStatsDAO($username = null) {
  41. $conf = Minz_Configuration::get('system');
  42. switch ($conf->db['type']) {
  43. case 'sqlite':
  44. return new FreshRSS_StatsDAOSQLite($username);
  45. case 'pgsql':
  46. return new FreshRSS_StatsDAOPGSQL($username);
  47. default:
  48. return new FreshRSS_StatsDAO($username);
  49. }
  50. }
  51. public static function createDatabaseDAO($username = null) {
  52. $conf = Minz_Configuration::get('system');
  53. switch ($conf->db['type']) {
  54. case 'sqlite':
  55. return new FreshRSS_DatabaseDAOSQLite($username);
  56. case 'pgsql':
  57. return new FreshRSS_DatabaseDAOPGSQL($username);
  58. default:
  59. return new FreshRSS_DatabaseDAO($username);
  60. }
  61. }
  62. }