4
0

Factory.php 2.0 KB

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