Newsletter.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /*
  3. * FecShop file.
  4. *
  5. * @link http://www.fecshop.com/
  6. * @copyright Copyright (c) 2016 FecShop Software LLC
  7. * @license http://www.fecshop.com/license/
  8. */
  9. namespace fecshop\services\page;
  10. //use fecshop\models\mongodb\customer\Newsletter as MongoNewsletter;
  11. use fecshop\services\Service;
  12. /**
  13. * Page Newsletter services.
  14. * @author Terry Zhao <2358269014@qq.com>
  15. * @since 1.0
  16. */
  17. class Newsletter extends Service
  18. {
  19. /**
  20. * $storagePrex , $storage , $storagePath 为找到当前的storage而设置的配置参数
  21. * 可以在配置中更改,更改后,就会通过容器注入的方式修改相应的配置值
  22. */
  23. public $storage = 'NewsletterMysqldb'; // NewsletterMysqldb | NewsletterMongodb 当前的storage,如果在config中配置,那么在初始化的时候会被注入修改
  24. /**
  25. * 设置storage的path路径,
  26. * 如果不设置,则系统使用默认路径
  27. * 如果设置了路径,则使用自定义的路径
  28. */
  29. public $storagePath = '';
  30. protected $_newsletter;
  31. public function init()
  32. {
  33. parent::init();
  34. $currentService = $this->getStorageService($this);
  35. $this->_newsletter = new $currentService();
  36. }
  37. // 动态更改为mongodb model
  38. public function changeToMongoStorage()
  39. {
  40. $this->storage = 'ReviewMongodb';
  41. $currentService = $this->getStorageService($this);
  42. $this->_newsletter = new $currentService();
  43. }
  44. // 动态更改为mongodb model
  45. public function changeToMysqlStorage()
  46. {
  47. $this->storage = 'ReviewMysqldb';
  48. $currentService = $this->getStorageService($this);
  49. $this->_newsletter = new $currentService();
  50. }
  51. public function subscription($email)
  52. {
  53. return $this->_newsletter->subscription($email);
  54. }
  55. /**
  56. * @param $filter|array
  57. * get subscription email collection
  58. */
  59. public function getSubscriptionList($filter)
  60. {
  61. return $this->_newsletter->getSubscriptionList($filter);
  62. }
  63. }